1. 程式人生 > >ffmpeg編譯安裝

ffmpeg編譯安裝

ffmpeg是什麼

 FFmpeg是一套可以用來記錄、轉換數字音訊、視訊,並能將其轉化為流的開源計算機程式。採用LGPL或GPL許可證。它提供了錄製、轉換以及流化音視訊的完整解決方案。它包含了非常先進的音訊/視訊編解碼庫libavcodec,為了保證高可移植性和編解碼質量,libavcodec裡很多code都是從頭開發的。

FFmpeg在Linux平臺下開發,但它同樣也可以在其它作業系統環境中編譯執行,包括Windows、Mac OS X等。這個專案最早由Fabrice Bellard發起,2004年至2015年間由Michael Niedermayer主要負責維護。許多FFmpeg的開發人員都來自MPlayer專案,而且當前FFmpeg也是放在MPlayer專案組的伺服器上。專案的名稱來自MPEG

視訊編碼標準,前面的"FF"代表"Fast Forward"。

一、安裝cmake

[[email protected] ~]# cmake --version

cmake version 2.8.12.2

[[email protected] cmake-3.5.0]# yum remove cmake -y

[[email protected] ffmpeg]# tar -xvf cmake-3.5.0.tar.gz

[[email protected] cmake-3.5.0]# cd cmake-3.5.0 && ./configure

[[email protected] cmake-3.5.0]# echo $?

0

[[email protected] cmake-3.5.0]# make && make install

[[email protected] cmake-3.5.0]# echo $?

0

[[email protected] bin]# cp /usr/local/bin/cmake /usr/bin/

[[email protected] bin]# ./cmake --version

cmake version 3.5.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

二、安裝yasm庫(提高編解碼效率)

[[email protected] ffmpeg]# tar xvf yasm-1.3.0.tar.gz

[[email protected] yasm-1.3.0]# ./configure

[[email protected] yasm-1.3.0]# make && make install

三、安裝h246編解碼庫

[[email protected] ffmpeg]# yum install -y bzip2

[[email protected] ffmpeg]# tar -xvf last_x264.tar.bz2

[[email protected] x264-snapshot-20160319-2245]# ./configure --enable-shared

[[email protected] x264-snapshot-20160319-2245]# make && make install

相關檔案位置:

h264庫的標頭檔案在/usr/local/include

動靜態庫在/usr/local/lib

x264.pc庫的配置檔案在/usr/local/lib/pkgconfig

四、安裝 h265 編解碼庫

[[email protected] x265_1.9]# tar -xvf x265_1.9.tar.gz

[[email protected] linux]# cd /root/ffmpeg/x265_1.9/build/linux

執行指令碼:

[[email protected] linux]# sh make-Makefiles.bash

執行時會彈出介面選項, 按'c'再按'g'鍵儲存退出

安裝:

[[email protected] linux]# make && make install

相關檔案位置:

h265庫的標頭檔案在/usr/local/include

 

五、安裝 ffmpeg

[[email protected] ffmpeg]# tar xvf ffmpeg-3.0.tar.bz2

設定環境變數

[[email protected] ffmpeg-3.0]# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

(這個是臨時的,如果需要永久生效需要寫進/etc/profile裡面)

安裝ffmpeg

[[email protected] ffmpeg-3.0]# ./configure --disable-debug --enable-libx264 --enable-libx265 --enable-gpl --enable-shared

[[email protected] ffmpeg-3.0]# make && make install

複製檔案

[[email protected] lib]# cp /usr/local/lib/libx* /lib64/

[[email protected] lib]# cp /usr/local/lib/libav* /lib64/

[[email protected] lib]# cp /usr/local/lib/libsw* /lib64/

[[email protected] lib]# cp /usr/local/lib/libpostproc* /lib64/

 

可能出現的問題:

在configure的時候

有報錯:enabled program:

解決:是否有ffplay(沒有的話,yum install SDL, 後再重新configure

 

 

需要使用的安裝包:

官網:http://ffmpeg.org/
百度雲下載地址:https://pan.baidu.com/s/1wlMFUV6olcDgVM5bMG0xRQ 密碼:tcnn

cmake-3.5.0.tar.gz

 

ffmpeg-3.0.tar.bz2

 

last_x264.tar.bz2

 

x265_1.9.tar.gz

 

yasm-1.3.0.tar.gz