MAC编译FFmpeg的遇到的问题及解决方法

本文记录了在macOSCatalina10.15环境下编译FFmpeg3.4.1时遇到的错误及解决方法,包括libfdk-aacenc组件的成员名错误与libx264组件的未声明标识符问题,以及执行ffplay、ffmpeg时出现的Segmentationfault:11错误。提供了解决这些问题的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下面是我在macOS Catalina 10.15编译FFmpeg 3.4.1时出现的问题,记录下来备忘。

如果不需要编译特别的版本的话,编译新版FFmpeg可能不会遇到,如下面1和2,新版FFmpeg已Fix。

1、libavcodec/libfdk-aacenc.c:289:35: error: no member named 'encoderDelay' in 'AACENC_InfoStruct'

    avctx->initial_padding = info.encoderDelay;

解决方法:

根据下面链接fix committed

https://github.com/libav/libav/commit/141c960e21d2860e354f9b90df136184dd00a9a8

2、编译过程出现如下错误(use of undeclared identifier 'x264_bit_depth'):

libavcodec/libx264.c:271:9: error: use of undeclared identifier 'x264_bit_depth'
    if (x264_bit_depth > 8)
        ^
libavcodec/libx264.c:898:9: error: use of undeclared identifier 'x264_bit_depth'
    if (x264_bit_depth == 8)
        ^
libavcodec/libx264.c:900:14: error: use of undeclared identifier 'x264_bit_depth'
    else if (x264_bit_depth == 9)
             ^
libavcodec/libx264.c:902:14: error: use of undeclared identifier 'x264_bit_depth'
    else if (x264_bit_depth == 10)

解决方法:

打开libx264.c,找到相应的代码行,将“x264_bit_depth”改成“X264_BIT_DEPTH”即可

http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=2a111c99a60fdf4fe5eea2b073901630190c6c93

static av_cold void X264_init_static(AVCodec *codec)
 {
-    if (x264_bit_depth == 8)
+    if (X264_BIT_DEPTH == 8)
         codec->pix_fmts = pix_fmts_8bit;
-    else if (x264_bit_depth == 9)
+    else if (X264_BIT_DEPTH == 9)
         codec->pix_fmts = pix_fmts_9bit;
-    else if (x264_bit_depth == 10)
+    else if (X264_BIT_DEPTH == 10)
         codec->pix_fmts = pix_fmts_10bit;
+    else /* X264_BIT_DEPTH == 0 */
+        codec->pix_fmts = pix_fmts;
 }

3、编译好后,在终端执行 ffplay、ffmepg时报 Segmentation fault: 11。这个问题貌似在macOS 10.15 Catalina才会出现。

$ ffmpeg 
Segmentation fault: 11

解决方法:

在编译执行./configure时,添加 --extra-cflags =“-fno-stack-check”,然后make distclean重新编译

./configure  --prefix=/usr/local --extra-cflags="-fno-stack-check" --enable-ffplay --enable-gpl --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libopus --enable-libxvid --samples=fate-suite

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值