- 官方提供的
srs-docker
中的ffmpeg
,未加入文字字幕滤镜remark: we remove the libfreetype which always cause build failed, you must add it manual if needed.
; ffmpeg
官方镜像中也未加入--enable-libfreetype
字幕滤镜
ffmpeg官方:http://ffmpeg.org/ffmpeg-filters.html#drawtext-1
srs-docker官方:srs/full.conf at 4.0release · ossrs/srs (github.com)
编译srs-docker
中的ffmpeg
,加入libfreetype
滤镜
构建环境为centos7
- 下载
libfreetype
包cd ~/ && wget \ https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.bz2
- 克隆
ffmpeg-srs-docker
cd ~/ && git clone -b dev \ https://github.com/ossrs/srs-docker.git srs-docker-ffmpeg
- 在
srs-docker/Dockerfile
中加入libfreetype
构建参数# 移动 mv ~/freetype-2.10.0.tar.bz2 ~/srs-docker-ffmpeg # 在For FFMPEG下加入 ADD freetype-2.10.0.tar.bz2 /tmp ··· cd /tmp/freetype-2.10.0 && ./configure --disable-shared --enable-static && make && make install && \
- 构建
srs-ffmpeg docker
镜像docker build -t xxxx
- 构建
srs-docker
镜像,加入内置的ffmpeg
# 克隆 git clone -b v4 https://github.com/ossrs/srs-docker.git srs-docker # 编辑Dockerfile cd srs-docker && vi Dockerfile # 在Dockerfile中的ffmpeg镜像地址使用自己构建的 ···
附件
ffmpeg
构建时的Dockerfile
#---------------------------build----------------------------------------------------- FROM centos:7 as build RUN yum install -y gcc gcc-c++ make patch sudo unzip perl zlib automake libtool \ zlib-devel bzip2 bzip2-devel libxml2-devel # Libs path for srt(depends on ssl) and ffmpeg(depends on serval libs). ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/ssl/lib/pkgconfig # Openssl 1.1.* for SRS. # ADD openssl-1.1.0e.tar.bz2 /tmp # RUN cd /tmp/openssl-1.1.0e && \ # ./config -shared -no-threads --prefix=/usr/local/ssl && make && make install_sw # Openssl 1.0.* for SRS. ADD openssl-OpenSSL_1_0_2u.tar.gz /tmp RUN cd /tmp/openssl-OpenSSL_1_0_2u && \ ./config -shared -no-threads --prefix=/usr/local/ssl && make && make install_sw # For FFMPEG ADD nasm-2.14.tar.bz2 /tmp ADD yasm-1.2.0.tar.bz2 /tmp ADD fdk-aac-0.1.3.tar.bz2 /tmp ADD lame-3.99.5.tar.bz2 /tmp ADD speex-1.2rc1.tar.bz2 /tmp ADD x264-snapshot-20181116-2245.tar.bz2 /tmp ADD freetype-2.10.0.tar.bz2 /tmp ADD ffmpeg-4.2.1.tar.bz2 /tmp RUN cd /tmp/nasm-2.14 && ./configure && make && make install && \ cd /tmp/yasm-1.2.0 && ./configure && make && make install && \ cd /tmp/fdk-aac-0.1.3 && bash autogen.sh && ./configure && make && make install && \ cd /tmp/lame-3.99.5 && ./configure && make && make install && \ cd /tmp/speex-1.2rc1 && ./configure && make && make install && \ cd /tmp/x264-snapshot-20181116-2245 && ./configure --disable-cli --enable-static && make && make install && \ cd /tmp/freetype-2.10.0 && ./configure --disable-shared --enable-static && make && make install && RUN cd /tmp/ffmpeg-4.2.1 && ./configure --enable-pthreads --extra-libs=-lpthread \ --enable-gpl --enable-nonfree --enable-libfreetype \ --enable-postproc --enable-bzlib --enable-zlib \ --enable-libx264 --enable-libmp3lame --enable-libfdk-aac --enable-libspeex \ --enable-libxml2 --enable-demuxer=dash \ --pkg-config-flags='--static' && \ (cd /usr/local/lib && mkdir -p tmp && mv *.so* *.la tmp && echo "Force use static libraries") && \ make && make install && echo "FFMPEG build and install successfully" && \ (cd /usr/local/lib && mv tmp/* . && rmdir tmp) #------------------------------------------------------------------------------------ #--------------------------dist------------------------------------------------------ #------------------------------------------------------------------------------------ FROM centos:7 as dist WORKDIR /tmp/srs # FFmpeg. COPY --from=build /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg COPY --from=build /usr/local/ssl /usr/local/ssl # Note that git is very important for codecov to discover the .codecov.yml RUN yum install -y gcc gcc-c++ make net-tools gdb lsof tree dstat redhat-lsb unzip zip git \ nasm perf strace sysstat ethtool libtool # Install cherrypy for HTTP hooks. ADD CherryPy-3.2.4.tar.gz2 /tmp RUN cd /tmp/CherryPy-3.2.4 && python setup.py install ENV PATH $PATH:/usr/local/go/bin RUN cd /usr/local && \ curl -L -O https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz && \ tar xf go1.13.5.linux-amd64.tar.gz && \ rm -f go1.13.5.linux-amd64.tar.gz ENV LIBRARY_PATH=/usr/local/lib64 ENV LD_LIBRARY_PATH=/usr/local/lib64
srs-docker Dockerfile
# https://docs.docker.com/engine/reference/builder/#arg # @remark Please never modify it, the auto/release.sh will update it automatically. ARG tag=v3.0-r2 ARG url=https://gitee.com/winlinvip/srs.oschina.git ############################################################ # build ############################################################ ARG repo=这里填入自己构建的ffmpeg镜像地址 FROM ${repo} AS build ARG tag ARG url # Install required tools. RUN yum install -y gcc make gcc-c++ patch unzip perl git RUN cd /tmp && git clone --depth=1 --branch ${tag} ${url} srs RUN cd /tmp/srs/trunk && ./configure && make && make install # All config files for SRS. COPY conf /usr/local/srs/conf # The default index.html and srs-console. COPY index.html /usr/local/srs/objs/nginx/html/index.html COPY srs-console/trunk/research/console /usr/local/srs/objs/nginx/html/console COPY font-blod.ttf /usr/local/srs/font-blod.ttf ############################################################ # dist ############################################################ FROM centos:7 AS dist # RTMP/9221, API/9220, HTTP/9223 EXPOSE 9221 9220 9223 # FFMPEG 4.1 COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg # SRS binary, config files and srs-console. COPY --from=build /usr/local/srs /usr/local/srs # Default workdir and command. WORKDIR /usr/local/srs ENV TIME_ZONE Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime CMD ["./objs/srs", "-c", "conf/srs.conf"]