安装依赖
我们编译FFmpeg集成fdk-aac
, x264
, x265
brew install yasm sdl2 fdk-aac x264 x265
查看是否安装成功
➜ ~ brew list | grep -E 'fdk|x26|sdl'
fdk-aac
sdl2
x264
x265
下载源码
git clone https://github.com/FFmpeg/FFmpeg.git
开始编译
进入到FFmpeg源码目录
切换到我们需要的分支版本
FFmpeg git:(master) ✗ git checkout n4.4.1
设置pkg-config的搜索路径
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
开始配置
./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265
开始编译
make -j 8
安装
sudo make install
查看下文件
ls /usr/local/ffmpeg
bin include lib share
ffmpeg version n4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
configuration: --prefix=/usr/local/ffmpeg --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
遇到的错误
错误一:没找到x265
➜ FFmpeg git:(n4.4.1) ✗ ./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265
ERROR: x265 not found using pkg-config
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
上面错误说明pkg-config没找到x265,我们设置下pkg-config的搜索路径就可以了
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/
我们搜索下x265,可以看到能搜索到了
pkg-config --list-all | grep x265
x265 x265 - H.265/HEVC video encoder
问题二:没到到SDL2
./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-sdl2
ERROR: sdl2 requested but not found
If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
配置参数带上-enable-sdl2
会报这个错误, 去掉这个参数就不会编译出来ffplay
,暂时先去掉