最近想跟中下 ffmpeg 相关的开发, 使用 docker 环境进行编译, 参考项目在 github 上。
对Dockfile做过一些调整后, 成功到ffmpeg编译步骤,但是ffmpeg 的编译命令中 --enable-libvorbis 和 --extra-libs=-static 两个选项有冲突,具体不清楚, 报 libm.so 库中 没有符号的错误
bash
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libvorbis.a(sharedbook.o): in function `_float32_pack':
(.text+0xd6): undefined reference to `__log_finite'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libvorbis.a(sharedbook.o): in function `_book_maptype1_quantvals':
(.text+0x444): undefined reference to `__pow_finite'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libvorbis.a(psy.o): in function `setup_tone_curves':
(.text+0x11e2): undefined reference to `__log_finite'
查看编译的日志 ffbuild/config.log 发现的问题, 我这里 关掉了 -static 的选项, 编译通过
测试程序:
c
// vorib_test.c
#include <vorbis/codec.h>
#include <stdint.h>
long check_vorbis_info_init(void) { return (long) vorbis_info_init; }
int main(void) { int ret = 0;
ret |= ((intptr_t)check_vorbis_info_init) & 0xFFFF;
return ret; }
bash
// gcc -D_ISOC11_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC --static -I/root/ffmpeg_build/include -std=c17 -fomit-frame-pointer -fPIC -pthread -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/opus -c vorib_test.c -o voribtest.o
// gcc voribtest.o -o voribtest -lvorbis -logg -lpthread -lm # -static
编译通过的Dockfile:
Dockfile
FROM harbor.hocker.com:19443/library/ubuntu:20.04
# Container for compiling ffmpeg and copying ffmpeg, ffprobe, and ffserver to the host operating system.
# If the host OS is not linux, another container could instead use the binary.
# Example build
# docker build -t ffmpeg-compiler .
# Example run
# docker run --rm -it -v $(pwd):/host ffmpeg-compiler bash -c "cp /root/bin/ffmpeg /root/bin/ffprobe /root/bin/ffserver /host && chown $(id -u):$(id -g) /host/ffmpeg && chown $(id -u):$(id -g) /host/ffprobe && chown $(id -u):$(id -g) /host/ffserver"
MAINTAINER srwareham
ENV TZ=Asia/Shanghai
# 安装 tzdata 包 运行配置脚本以设置时区
RUN sed -i s:/archive.ubuntu.com:/mirrors.tuna.tsinghua.edu.cn/ubuntu:g /etc/apt/sources.list \
&& apt-get update && apt-get install -y tzdata \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Get the dependencies
RUN set -x \
&& apt-get update \
&& apt-get -y install wget git curl autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev nasm\
&& mkdir ~/ffmpeg_sources \
&& apt-get -y install yasm \
&& cd ~/ffmpeg_sources \
&& wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz \
&& tar xzvf yasm-1.3.0.tar.gz \
&& cd yasm-1.3.0 \
&& ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" \
&& make -j$(cat /proc/cpuinfo | grep processor | wc -l) \
&& make install \
&& make distclean \
&& apt-get -y install libx264-dev \
&& apt-get -y install cmake mercurial \
&& echo COMPLETED PART 1
RUN set -x \
&& cd ~/ffmpeg_sources \
&& hg --version \
&& git clone https://github.com/videolan/x265.git \
&& cd ~/ffmpeg_sources/x265/build/linux \
&& PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source \
&& make -j$(cat /proc/cpuinfo | grep processor | wc -l) \
&& make install \
&& make clean \
&& cd ~/ffmpeg_sources \
&& wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master \
&& tar xzvf fdk-aac.tar.gz \
&& cd mstorsjo-fdk-aac* \
&& autoreconf -fiv \
&& ./configure --prefix="$HOME/ffmpeg_build" --disable-shared \
&& make -j$(cat /proc/cpuinfo | grep processor | wc -l) \
&& make install \
&& make distclean \
&& echo COMPLETED PART 2
RUN set -x \
&& echo install libmp3lame \
&& apt-get -y install libmp3lame-dev \
&& apt-get -y install libopus-dev \
&& cd ~/ffmpeg_sources \
&& wget https://github.com/webmproject/libvpx/archive/v1.8.2.tar.gz \
&& tar xzvf v1.8.2.tar.gz \
&& cd libvpx-1.8.2 \
&& PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests \
&& PATH="$HOME/bin:$PATH" make -j$(cat /proc/cpuinfo | grep processor | wc -l) \
&& make install \
&& make clean
# install ffmpeg
RUN cd ~/ffmpeg_sources \
&& wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 \
&& tar xjvf ffmpeg-snapshot.tar.bz2 \
&& cd ffmpeg \
&& PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig:$PKG_CONFIG_PATH" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-libs=-static \
--extra-cflags=--static \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
&& PATH="$HOME/bin:$PATH" make -j$(cat /proc/cpuinfo | grep processor | wc -l) \
&& make install \
&& make distclean \
&& hash -r
更新后的项目上传到 gitee 上。