[scode type="blue"]

我为什么不用HomeBrew方式安装呢?因为这种方式安装总是失败,可能是我系统版本的问题。

FFMpeg官方网址: http://www.ffmpeg.org
源码下载地址: http://www.ffmpeg.org/download.html
不同版本源码: http://www.ffmpeg.org/releases

[/scode]

我直接克隆GitHub上面的源码了,开始。

首先编译安装(末尾有常见错误的解决方法)

  1. 下载FFMpeg源代码

    cd ~/
    git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
  2. 下载完成后,进入FFMpeg源代码目录,运行配置命令

    ./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-videotoolbox --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --cc=clang --host-cflags= --host-ldflags= --disable-x86asm --extra-cflags="-fno-stack-check"
  3. 编译安装

    make && sudo make install
  4. 查看是否编译成功

    ll /usr/local/ffmpeg/bin/ffmpeg
  5. 添加环境变量

    vim ~/.bash_profile

    加入下面这行

    export PATH=$PATH:/usr/local/ffmpeg/bin

    wq退出,然后更新环境变量

    source  ~/.bash_profile
  6. 命令行中输入测试

    ffmpeg

可能遇到的问题

[scode type="yellow"]
ERROR: libfdk_aac not found

brew install fdk-aac

ERROR: x264 not found

brew install x264

ERROR: x265 not found

brew install x265

ERROR: speex not found

brew install speex

ERROR: pkg-config not found

brew install pkg-config

编译ffplay需要sdl2的支持

brew install sdl2

[/scode]

[post cid="286" cover=""/]