centos7環境下二進位制編譯安裝ffmpeg

sathcal發表於2024-11-09

yum install autoconf automake bzip2 cmake freetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
yum install -y automake libtool autoconf gcc gcc-c++ make automake cmake openssl openssl-devel


mkdir -p /usr/local/src/ffmpeg_sources
cd /usr/local/src/ffmpeg_sources

\# 安裝 nasm
cd /usr/local/src/ffmpeg_sources
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2
tar xjvf nasm-2.15.05.tar.bz2
cd nasm-2.15.05
./autogen.sh
./configure --prefix="/workspace/ffmpeg" --bindir="/usr/local/bin"
make -j 4
make install


\# 安裝 Yasm
cd /usr/local/src/ffmpeg_sources

curl -O -L https://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="/workspace/ffmpeg" --bindir="/usr/local/bin"
make -j 8
make install


\# 安裝 freetype-2

yum install -y bzip2

wget http://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.bz2

tar -jxvf freetype-2.10.0.tar.bz2

cd freetype-2.10.0

./configure --prefix="/workspace/ffmpeg" --disable-shared

make -j 8
make install



\# 安裝 libx264

cd /usr/local/src/ffmpeg_sources
git clone --branch stable --depth 1 https://code.videolan.org/videolan/x264.git
cd x264
PKG_CONFIG_PATH="/workspace/ffmpeg/lib/pkgconfig" ./configure --prefix="/workspace/ffmpeg" --bindir="/usr/local/bin" --enable-static
make -j 8
make install

\# 安裝 libx265

cd /usr/local/src/ffmpeg_sources
git clone --branch stable --depth 2 https://bitbucket.org/multicoreware/x265_git
cd /usr/local/src/ffmpeg_sources/x265_git/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/workspace/ffmpeg" -DENABLE_SHARED:bool=off ../../source
make -j 8
make install

\# 安裝 libfdk_aac

cd /usr/local/src/ffmpeg_sources
git clone --depth 1 https://github.com/mstorsjo/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="/workspace/ffmpeg" --disable-shared
make -j 8
make install


\# 安裝 libmp3lame

cd /usr/local/src/ffmpeg_sources
curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar xzvf lame-3.100.tar.gz
cd lame-3.100
./configure --prefix="/workspace/ffmpeg" --bindir="/usr/local/bin" --disable-shared --enable-nasm
make -j 8
make install

\# 安裝 libopus
cd /usr/local/src/ffmpeg_sources
curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar xzvf opus-1.3.1.tar.gz
cd opus-1.3.1
./configure --prefix="/workspace/ffmpeg" --disable-shared
make -j 8
make install


\# 安裝 libvpx

cd /usr/local/src/ffmpeg_sources
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git
cd libvpx
./configure --prefix="/workspace/ffmpeg" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm
make -j 8
make install

\# 安裝 FFmpeg

cat /etc/profile.d/zz_jdk.sh

export JAVA_HOME=/opt/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export MAVEN_HOME=/opt/maven
export M2_HOME=$MAVEN_HOME
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/workspace/ffmpeg/lib
export LD_LIBRARY_PATH
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$MAVEN_HOME/bin:/workspace/ffmpeg/bin

ERROR: freetype2 not found using pkg-config
ln -s /workspace/ffmpeg/include/freetype2/ft2build.h /workspace/ffmpeg/include/ft2build.h
ln -s /workspace/ffmpeg/include/freetype2/freetype /workspace/ffmpeg/include/freetype

cd /usr/local/src/ffmpeg_sources
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
PATH="/usr/local/bin:$PATH" PKG_CONFIG_PATH="/workspace/ffmpeg/lib/pkgconfig" ./configure \
--prefix="/workspace/ffmpeg" \
--pkg-config-flags="--static" \
--extra-cflags="-I/workspace/ffmpeg/include" \
--extra-ldflags="-L/workspace/ffmpeg/lib" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--bindir="/usr/local/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
make -j 8
make install

[root@eus-video-collaboration-file01:~]# ffmpeg -version
ffmpeg version N-102519-gdcb285d2b7 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration: --prefix=/usr/local/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/usr/local/ffmpeg_build/include --extra-ldflags=-L/usr/local/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/usr/local/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 57. 0.100 / 57. 0.100
libavcodec 59. 1.100 / 59. 1.100
libavformat 59. 2.100 / 59. 2.100
libavdevice 59. 0.100 / 59. 0.100
libavfilter 8. 0.101 / 8. 0.101
libswscale 6. 0.100 / 6. 0.100
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100


ffprobe -i mov.mp4 -show_streams -print_format json
ffmpeg -i mov.mp4 -c:v libx264 -profile:v baseline -level 3.0 -y movbaseline.mp4

相關文章