Linux下 FFmpeg 編譯安裝


FFmpeg是一套可以用來記錄、轉換數字音頻、視頻,並能將其轉化為流的開源計算機程序。

官網:http://ffmpeg.org

一、FFmpeg安裝

安裝依賴包:

yum install  libtheora-devel  libvorbis-devel

FFmpeg編譯安裝:

由於系統不同,會導致依賴也不盡相同,需根據報錯信息逐漸安裝依賴

wget http://ffmpeg.org/releases/ffmpeg-3.3.2.tar.bz2
tar jxvf ffmpeg-3.3.2.tar.bz2
cd ffmpeg-3.3.2

 

# 如下是個人需要的編譯參數,可以根據實際情況增減
./configure --prefix=/usr/local/ffmpeg \
--enable-shared \ --enable-libfdk-aac \ --enable-gpl \ --enable-nonfree \ --enable-postproc \ --enable-avfilter \ --enable-pthreads \ --enable-libmp3lame \ --enable-libtheora \ --enable-libvorbis \ --enable-libx264 \ --enable-libxvid \ --enable-decoder=libx264 \ --enable-encoder=libx264
 
make && make install


安裝后,查看版本
./bin/ffmpeg -version

 

轉碼:

ffmpeg -i input.mp4 output.avi

二、FFmpeg安裝錯誤解決

有的包下載緩慢,備用下載地址: http://pan.baidu.com/s/1hsEeSNM

  • 報錯:yasm/nasm not found or too old. Use --disable-yasm for a crippled build
# rpm包存在的話,可以直接yum安裝 yasm,沒有則編譯安裝
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -zxvf yasm.tar.gz
./configure
make
make install
  • 報錯:ERROR: libfdk_aac not found
https://sourceforge.net/projects/opencore-amr/files/fdk-aac/ 下載fdk-aac-0.1.5.tar.gz ./configure&& make && make install
  • 報錯:ERROR: libtheora not found
http://downloads.xiph.org/releases/theora/?C=M;O=D
libtheora-1.2.0alpha1.tar.gz
./configure && make && make install
  • 如下報錯:
*** Could not run Ogg test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means Ogg was incorrectly installed
*** or that you have moved Ogg since it was installed.
 
        
http://downloads.xiph.org/releases/ogg/?C=M;O=D
libogg-1.3.2.tar.gz
./configure && make && make install

 

  • 報錯:ERROR: libvorbis not found

 

http://downloads.xiph.org/releases/vorbis/
libvorbis-1.3.3.tar.gz

 

  

 

  • 報錯:ERROR: libmp3lame >= 3.98.3 not found
http://downloads.sourceforge.net/lame
https://sourceforge.net/projects/lame/files/lame/3.99/, 我下到的是lame-3.99.5.tar.gz ./configure && make && make install
  • 報錯:ERROR: libx264 not found
 git clone git://git.videolan.org/x264.git
./configure --enable-shared && make && make install

 

  • 報錯:ERROR: libxvid not found
http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
cd build/generic/
./configure && make && make install

 

  • 庫文件找不到時解決:

 

ldd /data/server/ffmpeg/bin/ffmpeg  # 查看依賴庫文件,找到no found的庫文件
find /  -name libavdevice.so    # 查找庫文件位置
vim/etc/ld.so.conf     # 如存在,添加庫文件位置
/data/server/ffmpeg/lib/    
ldconfig     # 重新加載,使新庫文件生效

 

 

3.動態鏈接庫

$ sudo vi /etc/ld.so.conf

include ld.so.conf.d/*.conf

/usr/local/ffmpeg/lib       ///usr/local/ffmpeg 目錄是我ffmpeg安裝目錄,根據你的安裝目錄改吧

$ sudo ldconfig

 

4. Ffmpeg 加入環境變量

vi /etc/profile
加入以下內容:
export PATH="/usr/local/ffmpeg/bin:$PATH"

然后保存並運行source /etc/profile

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM