【Linux】Centos下安裝ffmpeg

1、準備工做

一、系統環境:CentOS release 6.9 (Final)linux

二、安裝依賴包c++

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

2、安裝

若是您不須要特定的編碼器,能夠在編譯ffmpeg的時候不啓用git

根目錄默認爲github

cd /usr/local/src/

一、Yasm

Ysam是X264和FFmpeg使用的彙編程序。web

git clone --depth 1 git://github.com/yasm/yasm.git
cd yasm
autoreconf -fiv
./configure --prefix="$lib/ffmpeg_build" --bindir="$lib/bin"
make
make install
make distclean

二、libx264

libx264 視頻編碼器。更多說明和用法示例能夠參考:https://trac.ffmpeg.org/wiki/Encode/H.264編程

編譯參數:–enable-gpl –enable-libx264bash

git clone --depth 1 git://git.videolan.org/x264
cd x264
PKG_CONFIG_PATH="$lib/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$lib/ffmpeg_build" --bindir="$lib/bin" --enable-static
make
make install
make distclean

三、libx265

H.265/HEVC 視頻編碼器。更多說明和用法示例能夠參考:https://trac.ffmpeg.org/wiki/Encode/H.265curl

安裝教程:https://bitbucket.org/multicoreware/x265/wiki/Homeide

編譯參數:–enable-gpl –enable-libx265ui

hg clone https://bitbucket.org/multicoreware/x265
cd ~/ffmpeg_sources/x265/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$lib/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make
make install

四、libfdk_aac

AAC 音頻編碼器。

編譯參數:–enable-libfdk-aac (以及 –enable-nonfree 若是你添加了 –enable-gpl的話)

git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac
cd fdk-aac
autoreconf -fiv
./configure --prefix="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

五、libmp3lame

MP3 音頻編碼器.

編譯參數: –enable-libmp3lame

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="$lib/ffmpeg_build" --bindir="$lib/bin" --disable-shared --enable-nasm
make
make install
make distclean

六、libopus

Opus 音頻編解碼器.

編譯參數: –enable-libopus

git clone https://git.xiph.org/opus.git
cd opus
autoreconf -fiv
./configure --prefix="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

七、libogg

Ogg 比特流庫.。libtheora and libvorbis須要

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="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

八、libvorbis

Vorbis 音頻編碼器. 須要 libogg

編譯參數:–enable-libvorbis

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$lib/ffmeg_build/lib" CPPFLAGS="-I$lib/ffmpeg_build/include" ./configure --prefix="$lib/ffmpeg_build" --with-ogg="$lib/ffmpeg_build" --disable-shared
make
make install
make distclean

九、libvpx

VP8/VP9 視頻編碼器.

編譯參數: –enable-libvpx.

git clone https://github.com/webmproject/libvpx.git
cd libvpx
./configure --prefix="$lib/ffmpeg_build" --disable-examples
make
make install
make clean

十、FFmpeg

git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
./configure --prefix="$lib/ffmpeg_build" --extra-cflags="-I$lib/ffmpeg_build/include" --extra-ldflags="-L$lib/ffmpeg_build/lib" --bindir="$lib/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安裝指南:https://trac.ffmpeg.org/wiki/CompilationGuide

二、ffmpeg git地址:https://github.com/FFmpeg/FFmpeg

相關文章
相關標籤/搜索