Mac M1编译FFmpeg6.0

逻辑沙漏
• 阅读 1795

本文记录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"
点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
美凌格栋栋酱 美凌格栋栋酱
7个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Stella981 Stella981
3年前
M1 Mac使用原生Go与开发环境
Go1.16版将正式支持AppleSilicon M1芯片,即arm64架构的Mac操作系统,目前go1.16版版本为beta1,只是会在这个基础上再修修bug,改进文档等。目前有两种方式抢先体验Go1.16:方式一:编译源代码mac上需要确保安装有rosetta2(https://support.apple.com/
Stella981 Stella981
3年前
Flutter环境搭建
本文介绍mac上搭建Flutter环境1、Flutter官方提供中国地区镜像地址:https://github.com/flutter/flutter/wiki/UsingFlutterinChina(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fgithub.com%2Ff
Wesley13 Wesley13
3年前
Ubuntu 14.04 安装ffmpeg及开发库
Ubuntu14.04安装ffmpeg及开发库参考资料在官网有一篇比较全的教程CompilationGuide/Ubuntu(https://www.oschina.net/action/GoToLink?urlhttp%3A%2F%2Fhttp%3A%2F%2Ftrac.ffmp
Stella981 Stella981
3年前
Groovy防PermOOM与OldOOM心得
作为Groovy重度用户,踩了新版本因为无法unloadclass导致permoom的坑,踩了classLoader.parallelLockMap不断添加新锁导致oldoom的坑。本文的意图就是记录一点埋坑心得。踩坑详情可见:https://my.oschina.net/chenxiaojie/blog/835934(https://my.o
Wesley13 Wesley13
3年前
MySQLStudy——Mac下MySQL 常用命令 启动 关闭 重启服务 查看版本
MAC下MySQL常用命令本人电脑为MacOS10.14版本MySQL为8.0.15版本查看mysql版本方法一:status;!(https://oscimg.oschina.net/oscnet/01e3f478
Wesley13 Wesley13
3年前
HTTP面试题(二):HTTP请求报文和响应报文格式
!(https://oscimg.oschina.net/oscnet/0406894fb1274bee91fc53c84c516576.jpg)看都看了还不点个赞!(https://oscimg.oschina.net/oscnet/095d444dc9a449ee85afd19b00fdf52b.png)!(h
Stella981 Stella981
3年前
Impala常用函数索引
增加X自然天selectdays_add(now(),2)字符串转Timestampselectto\_timestamp('2019101420:00:01','yyyyMMddHH:mm:ss');注意,Impala的timestamp的标准是ISO8601 参考:https://en.wiki
Skia 编译及踩坑实践
本文要点•了解并入门Skia、OpenGL和Vulkan•了解Skia在后端渲染上的坑点前言Skia是什么Skia是一个开源2D图形库,提供可跨各种硬件和软件平台工作的通用API。它充当GoogleChrome和ChromeOS、Android、Flutt