共计 5315 个字符,预计需要花费 14 分钟才能阅读完成。
本文记录 mac m1 电脑上手动编译 FFmpeg6.0 的踩坑问题
参考官网文档:https://trac.ffmpeg.org/wiki/CompilationGuide/macOS
版本信息
名称 | 版本 |
---|---|
macOS | 13.4 |
芯片 | Apple M1 |
FFmpeg | 6.0 |
下载 FFmpeg 源码
git clone <https://github.com/FFmpeg/FFmpeg.git>
cd FFmpeg
git checkout origin/release/6.0
装置依赖
根本笼罩了所需的装置依赖,如果在配置编译信息时报错请参考 问题汇总
brew install automake fdk-aac git lame libass libtool libvorbis libvpx \\
opus sdl shtool texi2html wget x264 x265 nasm \\
libbluray dav1d libgsm libmodplug opencore-amr openh264 openjpeg rubberband \\
snappy libsoxr speex theora two-lame libvidstab xvid zimg zmq
配置编译信息
./configure \\
--cc=/usr/bin/clang \\
--prefix=/Users/kejie/code/ffmpeg \\
--extra-version=tessus \\
--enable-avisynth \\
--enable-fontconfig \\
--enable-gpl \\
--enable-libaom \\
--enable-libass \\
--enable-libbluray \\
--enable-libdav1d \\
--enable-libfreetype \\
--enable-libgsm \\
--enable-libmodplug \\
--enable-libmp3lame \\
--enable-libmysofa \\
--enable-libopencore-amrnb \\
--enable-libopencore-amrwb \\
--enable-libopenh264 \\
--enable-libopenjpeg \\
--enable-libopus \\
--enable-librubberband \\
--enable-libshine \\
--enable-libsnappy \\
--enable-libsoxr \\
--enable-libspeex \\
--enable-libtheora \\
--enable-libtwolame \\
--enable-libvidstab \\
--enable-libvmaf \\
--enable-libvo-amrwbenc \\
--enable-libvorbis \\
--enable-libvpx \\
--enable-libwebp \\
--enable-libx264 \\
--enable-libx265 \\
--enable-libxavs \\
--enable-libxvid \\
--enable-libzimg \\
--enable-libzmq \\
--enable-libzvbi \\
--enable-version3 \\
--pkg-config-flags=--static \\
--disable-ffplay \\
--extra-cflags="-I/opt/homebrew/Cellar/libgsm/1.0.22/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/libgsm/1.0.22/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/lame/3.100/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/lame/3.100/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/opencore-amr/0.1.6/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/opencore-amr/0.1.6/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/snappy/1.1.10/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/snappy/1.1.10/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/libsoxr/0.1.3/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/libsoxr/0.1.3/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/theora/1.1.1/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/theora/1.1.1/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/libogg/1.3.5/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/libogg/1.3.5/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/two-lame/0.4.0/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/two-lame/0.4.0/lib" \\
--extra-cflags="-I/opt/homebrew/Cellar/xvid/1.3.7/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/xvid/1.3.7/lib"
make
# 启动 make 具备等于零碎上最大逻辑 CPU 数量的并行作业的过程,放慢编译速度。make -j `sysctl -n hw.logicalcpu_max`
make install
问题汇总
1、ERROR: avisynth/avisynth_c.h avisynth/avs/version.h not found
解决办法:
mac 装置 https://github.com/AviSynth/AviSynthPlus/releases
2、找不到 ERROR: libbluray not found using pkg-config
brew install libbluray
3、ERROR: dav1d >= 0.5.0 not found using pkg-config
brew install dav1d
4、ERROR: libgsm not found
brew install libgsm
5、ERROR: libmodplug not found using pkg-config
brew install libmodplug
6、ERROR: libmysofa not found
git clone <https://github.com/hoene/libmysofa.git>
cd ./libmysofa/build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF ..
make && make insall
7、ERROR: libopencore_amrnb not found
brew install opencore-amr
8、ERROR: openh264 not found using pkg-config
brew install openh264
9、ERROR: libopenjp2 >= 2.1.0 not found using pkg-config
brew install openjpeg
10、ERROR: rubberband >= 1.8.1 not found using pkg-config
brew install rubberband
11、ERROR: shine not found using pkg-config
git clone <https://github.com/toots/shine.git>
cd ./shine
./bootstrap
./configure --prefix=/usr/local --disable-shared
make && make install
12、ERROR: libsnappy not found
brew install snappy
13、ERROR: libsoxr not found
brew install libsoxr
14、ERROR: speex not found using pkg-config
brew install speex
15、ERROR: libtheora not found
brew install theora
16、/opt/homebrew/Cellar/theora/1.1.1/include/theora/theoraenc.h:24:11: fatal error: ‘ogg/ogg.h’ file not found
# 减少 flags
# 先查找 ogg.h 文件寄存在哪里
find /opt -name "ogg.h"
.....
--extra-cflags="-I/opt/homebrew/Cellar/libogg/1.3.5/include" \\
--extra-ldflags="-L/opt/homebrew/Cellar/libogg/1.3.5/lib"
17、ERROR: libtwolame not found
brew install two-lame
18、ERROR: vidstab >= 0.98 not found using pkg-config
brew install libvidstab
19、ERROR: libvo_amrwbenc not found
# 下载 opencore-amr 库
# <https://sourceforge.net/projects/opencore-amr/files/vo-amrwbenc/vo-amrwbenc-0.1.3.tar.gz/download>
wget <https://nchc.dl.sourceforge.net/project/opencore-amr/vo-amrwbenc/vo-amrwbenc-0.1.3.tar.gz>
tar -zxf vo-amrwbenc-0.1.3.tar.gz
./configure --prefix=/usr/local --disable-shared
make && make install
20、ERROR: libxavs not found
# 下载源码 <https://sourceforge.net/p/xavs/code/HEAD/tree/>
wget <https://sourceforge.net/code-snapshots/svn/x/xa/xavs/code/xavs-code-r55-trunk.zip>
unzip xavs-code-r55-trunk.zip
cd ./xavs-code-r55-trunk
#!!留神 mac 的架构
# ./configure --prefix=/usr/local --host=x86_64-darwin --disable-asm
./configure --prefix=/usr/local --host=arm-darwin --disable-asm
make && make install
# ------------ 分割线 -----------------
# 如果 第一次执行谬误的./configure 并且 make 生成了谬误的文件,须要上面操作
make clean
# 而后再执行
make && make install
21、ERROR: libxvid not found
brew install xvid
22、ERROR: zimg >= 2.7.0 not found using pkg-config
brew install zimg
23、ERROR: libzmq >= 4.2.1 not found using pkg-config
brew install zmq
24、ERROR: zvbi-0.2 not found using pkg-config
# 源码地址 <https://sourceforge.net/projects/zapping/files/zvbi/>
wget <https://nchc.dl.sourceforge.net/project/zapping/zvbi/0.2.35/zvbi-0.2.35.tar.bz2>
tar -jxf zvbi-0.2.35.tar.bz2
./configure --prefix=/usr/local --disable-shared
make && make install