srs-docker重新编译ffmpeg

  • 官方提供的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

  1. 下载libfreetype
    cd ~/ && wget \
    https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.bz2
    
  2. 克隆ffmpeg-srs-docker
    cd ~/ && git clone -b dev \
    https://github.com/ossrs/srs-docker.git srs-docker-ffmpeg
    
  3. 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 && \
    
  4. 构建srs-ffmpeg docker镜像
    docker build -t xxxx
    
  5. 构建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"]
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值