環境
系統環境:CentOS release 6.7 (Final)
需求
編譯安裝ffmpeg
獲取依賴
安裝依賴包
yum install -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel
創建編譯源碼的目錄
mkdir ~/ffmpeg_sources
編譯&安裝
Note:如果您不需要特定的編碼器,可以跳過相關部分,然后刪除編譯ffmpeg 時相應的./configure選項。例如,如果不需要libvorbis ,可以跳過這一節,然后從安裝ffmpeg的部分去掉–enable-libvorbis
Yasm
Ysam是X264和FFmpeg使用的匯編程序。
cd ~/ffmpeg_sources git clone --depth 1 git://github.com/yasm/yasm.git cd yasm autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make make install make distclean
libx264
libx264 視頻編碼器。更多說明和用法示例可以參考:https://trac.ffmpeg.org/wiki/Encode/H.264
需要ffmpeg編譯的時候添加–enable-gpl –enable-libx264
cd ~/ffmpeg_sources git clone --depth 1 git://git.videolan.org/x264 cd x264 PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static make make install make distclean
libx265
H.265/HEVC 視頻編碼器。更多說明和用法示例可以參考:https://trac.ffmpeg.org/wiki/Encode/H.265
需要ffmpeg編譯的時候添加–enable-gpl –enable-libx265
cd ~/ffmpeg_sources hg clone https://bitbucket.org/multicoreware/x265 cd ~/ffmpeg_sources/x265/build/linux cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source make make install
libfdk_aac
AAC 音頻編碼器。
需要ffmpeg編譯的時候添加–enable-libfdk-aac (以及 –enable-nonfree 如果你添加了 –enable-gpl的話)
cd ~/ffmpeg_sources
git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac cd fdk-aac autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libmp3lame
MP3 音頻編碼器.
需要ffmpeg編譯的時候添加 –enable-libmp3lame
cd ~/ffmpeg_sources
curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz tar xzvf lame-3.99.5.tar.gz cd lame-3.99.5 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm make make install make distclean
libopus
Opus 音頻編解碼器.
需要ffmpeg編譯的時候添加 –enable-libopus
cd ~/ffmpeg_sources
git clone https://git.xiph.org/opus.git cd opus autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libogg
Ogg 比特流庫.。libtheora and libvorbis需要
cd ~/ffmpeg_sources
curl -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz tar xzvf libogg-1.3.2.tar.gz cd libogg-1.3.2 ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install make distclean
libvorbis
Vorbis 音頻編碼器. 需要 libogg
需要ffmpeg編譯的時候添加 –enable-libvorbis
cd ~/ffmpeg_sources curl -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz tar xzvf libvorbis-1.3.4.tar.gz cd libvorbis-1.3.4 LDFLAGS="-L$HOME/ffmeg_build/lib" CPPFLAGS="-I$HOME/ffmpeg_build/include" ./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-shared make make install
libvpx
VP8/VP9 視頻編碼器.
需要ffmpeg編譯的時候添加 –enable-libvpx.
cd ~/ffmpeg_sources
git clone https://github.com/webmproject/libvpx.git cd libvpx ./configure --prefix="$HOME/ffmpeg_build" --disable-examples make make install make clean
FFmpeg
cd ~/ffmpeg_sources
git clone https://github.com/FFmpeg/FFmpeg.git cd FFmpeg export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --pkg-config-flags="--static" --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 make make install make distclean hash -r
至此,編譯ffmpeg完成, ffmpeg (包括 ffprobe, ffserver, lame, 和 x264已經可以使用
Done ^^
參考:
ffmpeg安裝指南:https://trac.ffmpeg.org/wiki/CompilationGuide
ffmpeg安裝指南(centos):https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
ffmpeg Git地址:https://github.com/FFmpeg/FFmpeg
安裝成功后檢測是否成功安裝:ffmpeg
進行轉碼:
