Mac M1编译FFmpeg6.0

本文记录mac m1电脑上手动编译FFmpeg6.0的踩坑问题

参考官方文档:https://trac.ffmpeg.org/wiki/CompilationGuide/macOS

版本信息

名称版本
macOS13.4
芯片Apple M1
FFmpeg6.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=/opt/homebrew/opt/llvm/bin/clang \
  --prefix=/Users/kejie/code/ffmpeg \
  --arch=arm64 \
  --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/usr/local/include" \
  --extra-ldflags="-L/usr/local/lib" \
  --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" \
  --extra-cflags="-I/opt/homebrew/Cellar/aom/3.6.1/include" \
  --extra-ldflags="-L/opt/homebrew/Cellar/aom/3.6.1/bin" \

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

llvm问题

# command-line-arguments
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
Undefined symbols for architecture arm64:

安装 arm64 架构的 llvm

arch=arm64 brew install llvm

安装完成提示

To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++"

llvm is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值