添加 avfilter 后编译 FFMPEG / libav 代码时出错
Error compiling FFMPEG / libav code after adding avfilter
我的编码和解码使用 ffmpeg 和 libav 工作正常,但后来我在编码步骤中添加了一个过滤器来旋转我的视频,它不再在我的 docker 机器上工作,但它在本地工作.
在docker编译时的错误信息是
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_init':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:56: undefined reference to `pp_get_mode_by_name_and_quality'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_uninit':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:161: undefined reference to `pp_free_mode'
/var/tmp/ffmpeg/libavfilter/vf_pp.c:163: undefined reference to `pp_free_context'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_filter_frame':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:142: undefined reference to `pp_postprocess'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_config_props':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:115: undefined reference to `pp_get_context'
collect2: error: ld returned 1 exit status
这些是我在docker文件
中的相关配置
# Install libx264 for video encoding.
RUN cd /var/tmp && curl -L http://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190103-2245-stable.tar.bz2 > x264.tar.bz2 && \
echo "21cb6e2bb660f863713fb9f752654c65191e032dac1329ec113786c69f0f75c1 x264.tar.bz2" > x264.sha256sum && \
shasum -a 256 -c x264.sha256sum && \
tar xjf x264.tar.bz2 && \
cd x264-snapshot-20190103-2245-stable && \
./configure \
--enable-static \
--enable-pic \
--disable-cli \
--disable-avs \
--disable-opencl && \
make -j8 && \
make install-lib-static
# Compile ffmpeg.
COPY ffmpeg.tar /var/tmp/ffmpeg.tar
RUN cd /var/tmp && tar xf ffmpeg.tar && \
cd ffmpeg && \
./configure \
--cc=/usr/bin/clang-6.0 \
--cxx=/usr/bin/clang++-6.0 \
--extra-libs="-lpthread" \
--enable-gpl \
# without pic - opencv will throw up errors
--enable-pic \
--enable-libx264 \
--disable-network && \
make -j 8 && \
make install
不确定这是否相关,但这是我的标志
LDFLAGS: -lavcodec -lavfilter -lswscale -lavutil -lswresample -lx264 -lm -lz
这是我本地的ffmpeg配置和版本
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
这是我的docker机器
的输出
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with clang version 6.0.0-1~bpo9+1 (tags/RELEASE_600/final)
configuration: --cc=/usr/bin/clang-6.0 --cxx=/usr/bin/clang++-6.0 --extra-libs=-lpthread --enable-gpl --enable-pic --enable-libx264 --disable-network
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
如何修复我的配置,使其像在本地一样工作?我没有专门配置我的本地环境,所以它将使用默认配置。
您的 LDFLAGS 中缺少 -lpostproc
。另外,顺序应该是正确的:
LDFLAGS=-lavfilter -lswscale -lpostproc -lswresample -lavcodec -lavutil -lx264 -lm -lz
我的编码和解码使用 ffmpeg 和 libav 工作正常,但后来我在编码步骤中添加了一个过滤器来旋转我的视频,它不再在我的 docker 机器上工作,但它在本地工作.
在docker编译时的错误信息是
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_init':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:56: undefined reference to `pp_get_mode_by_name_and_quality'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_uninit':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:161: undefined reference to `pp_free_mode'
/var/tmp/ffmpeg/libavfilter/vf_pp.c:163: undefined reference to `pp_free_context'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_filter_frame':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:142: undefined reference to `pp_postprocess'
//usr/local/lib/libavfilter.a(vf_pp.o): In function `pp_config_props':
/var/tmp/ffmpeg/libavfilter/vf_pp.c:115: undefined reference to `pp_get_context'
collect2: error: ld returned 1 exit status
这些是我在docker文件
中的相关配置# Install libx264 for video encoding.
RUN cd /var/tmp && curl -L http://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190103-2245-stable.tar.bz2 > x264.tar.bz2 && \
echo "21cb6e2bb660f863713fb9f752654c65191e032dac1329ec113786c69f0f75c1 x264.tar.bz2" > x264.sha256sum && \
shasum -a 256 -c x264.sha256sum && \
tar xjf x264.tar.bz2 && \
cd x264-snapshot-20190103-2245-stable && \
./configure \
--enable-static \
--enable-pic \
--disable-cli \
--disable-avs \
--disable-opencl && \
make -j8 && \
make install-lib-static
# Compile ffmpeg.
COPY ffmpeg.tar /var/tmp/ffmpeg.tar
RUN cd /var/tmp && tar xf ffmpeg.tar && \
cd ffmpeg && \
./configure \
--cc=/usr/bin/clang-6.0 \
--cxx=/usr/bin/clang++-6.0 \
--extra-libs="-lpthread" \
--enable-gpl \
# without pic - opencv will throw up errors
--enable-pic \
--enable-libx264 \
--disable-network && \
make -j 8 && \
make install
不确定这是否相关,但这是我的标志
LDFLAGS: -lavcodec -lavfilter -lswscale -lavutil -lswresample -lx264 -lm -lz
这是我本地的ffmpeg配置和版本
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
这是我的docker机器
的输出ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with clang version 6.0.0-1~bpo9+1 (tags/RELEASE_600/final)
configuration: --cc=/usr/bin/clang-6.0 --cxx=/usr/bin/clang++-6.0 --extra-libs=-lpthread --enable-gpl --enable-pic --enable-libx264 --disable-network
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
如何修复我的配置,使其像在本地一样工作?我没有专门配置我的本地环境,所以它将使用默认配置。
您的 LDFLAGS 中缺少 -lpostproc
。另外,顺序应该是正确的:
LDFLAGS=-lavfilter -lswscale -lpostproc -lswresample -lavcodec -lavutil -lx264 -lm -lz