Skip to content

Commit

Permalink
CentOS7: Add libx265 and static link FFmpeg.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 28, 2022
1 parent 6075e0f commit 0691d01
Showing 1 changed file with 58 additions and 12 deletions.
70 changes: 58 additions & 12 deletions Dockerfile
Expand Up @@ -7,15 +7,14 @@ ARG JOBS=2
RUN echo "JOBS: $JOBS"

RUN yum install -y gcc gcc-c++ make patch sudo unzip perl zlib automake libtool \
zlib-devel bzip2 bzip2-devel libxml2-devel \
tcl cmake
zlib-devel bzip2 bzip2-devel tcl

# Libs path for app which depends on ssl, such as libsrt.
ENV PKG_CONFIG_PATH $PKG_CONFIG_PATH:/usr/local/ssl/lib/pkgconfig
ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/ssl/lib/pkgconfig

# Libs path for FFmpeg(depends on serval libs), or it fail with:
# ERROR: speex not found using pkg-config
ENV PKG_CONFIG_PATH $PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
ENV PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig

# Openssl 1.1.* for SRS.
ADD openssl-1.1.1j.tar.bz2 /tmp
Expand All @@ -27,6 +26,11 @@ RUN cd /tmp/openssl-1.1.1j && \
#RUN cd /tmp/openssl-OpenSSL_1_0_2u && \
# ./config -no-shared -no-threads --prefix=/usr/local/ssl && make -j${JOBS} && make install_sw

# Build cmake for openssl, libsrt and libx265.
ADD CMake-3.22.5.tar.gz /tmp
RUN cd /tmp/CMake-3.22.5 && ./bootstrap && make -j${JOBS} && make install
ENV PATH=$PATH:/usr/local/bin

# For FFMPEG
ADD nasm-2.14.tar.bz2 /tmp
RUN cd /tmp/nasm-2.14 && ./configure && make -j${JOBS} && make install
Expand All @@ -39,9 +43,13 @@ RUN cd /tmp/lame-3.100 && ./configure --disable-shared && make -j${JOBS} && make
# For libx264
ADD x264-snapshot-20181116-2245.tar.bz2 /tmp
RUN cd /tmp/x264-snapshot-20181116-2245 && ./configure --disable-cli --disable-shared --enable-static && make -j${JOBS} && make install
# The libsrt for SRS, which depends on openssl.
# The libsrt for SRS, which depends on openssl and cmake.
ADD srt-1.4.1.tar.gz /tmp
RUN cd /tmp/srt-1.4.1 && ./configure --disable-shared --enable-static && make -j${JOBS} && make install
# For libxml2.
RUN yum install -y python-devel
ADD libxml2-2.9.12.tar.gz /tmp
RUN cd /tmp/libxml2-2.9.12 && ./autogen.sh && ./configure --disable-shared --enable-static && make -j${JOBS} && make install

# Build FFmpeg, static link libraries.
ADD ffmpeg-4.2.1.tar.bz2 /tmp
Expand All @@ -51,7 +59,41 @@ RUN cd /tmp/ffmpeg-4.2.1 && ./configure --enable-pthreads --extra-libs=-lpthread
--enable-libx264 --enable-libmp3lame --enable-libfdk-aac \
--enable-libxml2 --enable-demuxer=dash \
--enable-libsrt --pkg-config-flags='--static' && \
make -j${JOBS} && make install && echo "FFMPEG build and install successfully"
make -j${JOBS} && make install && echo "FFMPEG4 build and install successfully"
RUN cp /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg4

# For libx265. Note that we force to generate the x265.pc by replace X265_LATEST_TAG.
# if(X265_LATEST_TAG)
# configure_file("x265.pc.in" "x265.pc" @ONLY)
ADD x265-3.5_RC2.tar.bz2 /tmp
RUN cd /tmp/x265-3.5_RC2/build/linux && \
sed -i 's/^if(X265_LATEST_TAG)/if(TRUE)/g' ../../source/CMakeLists.txt && \
cmake -DENABLE_SHARED=OFF ../../source && make -j${JOBS} && make install

# Build FFmpeg, static link libraries.
ADD ffmpeg-5.0.2.tar.bz2 /tmp
RUN cd /tmp/ffmpeg-5.0.2 && ./configure --enable-pthreads --extra-libs=-lpthread \
--pkg-config-flags='--static' \
--enable-gpl --enable-nonfree \
--enable-postproc --enable-bzlib --enable-zlib \
--enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libfdk-aac \
--enable-libxml2 --enable-demuxer=dash \
--enable-libsrt && \
make -j${JOBS} && make install && echo "FFMPEG5 build and install successfully"
RUN cp /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg5

# Build FFmpeg, static link libraries.
ADD ffmpeg_rtmp_h265-5.0.tar.bz2 /tmp
RUN cp -f /tmp/ffmpeg_rtmp_h265-5.0/*.h /tmp/ffmpeg_rtmp_h265-5.0/*.c /tmp/ffmpeg-5.0.2/libavformat
RUN cd /tmp/ffmpeg-5.0.2 && ./configure --enable-pthreads --extra-libs=-lpthread \
--pkg-config-flags='--static' \
--enable-gpl --enable-nonfree \
--enable-postproc --enable-bzlib --enable-zlib \
--enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libfdk-aac \
--enable-libxml2 --enable-demuxer=dash \
--enable-libsrt && \
make -j${JOBS} && make install && echo "FFMPEG5(HEVC over RTMP) build and install successfully"
RUN cp /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg5-hevc-over-rtmp

#------------------------------------------------------------------------------------
#--------------------------dist------------------------------------------------------
Expand All @@ -60,17 +102,21 @@ FROM centos:7 as dist

ARG JOBS=2
ARG NO_GO
RUN echo "JOBS: $JOBS, NO_GO: $NO_GO"
RUN echo "NO_GO: $NO_GO, JOBS: $JOBS"

WORKDIR /tmp/srs

# FFmpeg.
COPY --from=build /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=build /usr/local/bin/ffmpeg4 /usr/local/bin/ffmpeg4
COPY --from=build /usr/local/bin/ffmpeg5 /usr/local/bin/ffmpeg5
COPY --from=build /usr/local/bin/ffmpeg5-hevc-over-rtmp /usr/local/bin/ffmpeg5-hevc-over-rtmp
RUN ln -sf /usr/local/bin/ffmpeg5-hevc-over-rtmp /usr/local/bin/ffmpeg
COPY --from=build /usr/local/bin/ffprobe /usr/local/bin/ffprobe
# OpenSSL.
COPY --from=build /usr/local/ssl /usr/local/ssl
# For libsrt
COPY --from=build /usr/local/include/srt /usr/local/include/srt
COPY --from=build /usr/local/lib64 /usr/local/lib64
#COPY --from=build /usr/local/include/srt /usr/local/include/srt
#COPY --from=build /usr/local/lib64 /usr/local/lib64

# 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 \
Expand All @@ -84,8 +130,8 @@ RUN yum install -y graphviz
RUN yum install -y libasan

# Install cherrypy for HTTP hooks.
ADD CherryPy-3.2.4.tar.gz2 /tmp
RUN cd /tmp/CherryPy-3.2.4 && python setup.py install
#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 if [[ -z $NO_GO ]]; then \
Expand Down

0 comments on commit 0691d01

Please sign in to comment.