<p>由于公司門店錄制的視頻都是wmv和avi的視頻曹宴,我們的視頻脫敏過后需要在手機端APP上顯示彭雾,APP端人員說Android不支持WMV格式的在線播放髓迎,安裝插件也沒有辦法硅瞧。所以就只能我們這邊脫敏之后再進行視頻解碼偏瓤,需要使用ffmpeg杀怠。</p>
一、首先是安裝各種解碼器</h3>
1厅克、lame
wget https://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar -zxvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --enable-shared
make
make install
2驮肉、libogg
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz
tar -zxvf libogg-1.3.2.tar.gz
cd libogg-1.3.2
./configure --enable-shared
make
make install
3、libvorbis
#libvorbis依賴于libogg, 所以libogg必須先于libvorbis安裝
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz
tar -zxvf libvorbis-1.3.5.tar.gz
cd libvorbis-1.3.5
./configure --enable-shared
make
make install
4已骇、xvidcore
wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
tar -zxvf xvidcore-1.3.2.tar.gz
cd xvidcore/build/generic
./configure --enable-shared
make
make install
5离钝、x264
last_x264.tar.bz2包
因為沒有找到好的資源,給一個ftp資源褪储,下載最新版本之后上傳到linux上
ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
tar -jxvf last_x264.tar.bz2
cd x264-snapshot-20170330-2245
./configure --enable-shared
make
make install
6卵渴、libdts
wget http://down1.chinaunix.net/distfiles/ffmpeg-0.5.tar.bz2
tar -jxvf libdca-0.0.5.tar.bz2
cd libdca-0.0.5
./configure --enable-shared
make
make install
7、faad2
wget https://jaist.dl.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
tar -zxvf faad2-2.7.tar.gz
cd faad2-2.7
./configure --enable-shared
make
make install
8鲤竹、faac
wget https://jaist.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
tar -zxvf faac-1.28.tar.gz
cd faac-1.28
./configure --enable-shared
make
make install
編譯FAAC-1.28時遇到錯誤
[mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’]
找到mpeg4ip.h并修改修改
解決方法:
從123行開始修改此文件mpeg4ip.h浪读,到129行結(jié)束昔榴。
修改前:
#ifdef __cplusplus
extern "C" {
#endif
char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif
修改后:
#ifdef __cplusplus
extern "C++" {
#endif
const char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif
9、amr-nb
wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-10.0.0.0.tar.bz2
tar -jxvf amrnb-10.0.0.0.tar.bz2
cd amrnb-11.0.0.0
./configure --enable-shared
make
make install
10碘橘、amr-wb
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-11.0.0.0.tar.bz2
tar -jxvf amrwb-11.0.0.0.tar.bz2
cd amrwb-11.0.0.0
./configure --enable-shared
make
make install
二互订、安裝yasm
#ffmpeg編譯中為了提高編譯速度,使用了匯編指令痘拆,于是需要使用這個工具仰禽。
yum -y install yasm
三、安裝ffmpeg
wget http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.bz2
tar -jxvf http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.bz2
cd ffmpeg-3.2.4
#其中–enable-shared表示生成動態(tài)鏈接庫纺蛆,可以供以后編程使用吐葵,同時生成的可執(zhí)行程序也依賴這些動態(tài)庫。如果不加上–enable-shared選項則使用靜態(tài)鏈接的方式編譯桥氏,此時不會生成動態(tài)庫温峭,同時生成的ffmpeg等的可執(zhí)行文件也比較大,但他們不需要動態(tài)庫就可以直接運行
./configure --enable-shared
#編譯字支,需要較長時間凤藏,10分鐘左右。
make
#安裝
make install
#安裝完成后
vi /etc/ld.so.conf.d/
把/usr/local/ffmpeg/lib填寫到該文件中
再執(zhí)行l(wèi)dconfig堕伪,更新ld.so.cache揖庄,使修改生效。
#測試安裝是否成功
cd /usr/local/ffmpeg/bin
#執(zhí)行
./ffmpeg
#出現(xiàn)如下內(nèi)容說明安裝成功
ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
configuration: --enable-shared --prefix=/usr/local/ffmpeg
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
四刃跛、使用ffmpeg轉(zhuǎn)換視頻
#ffmpeg常用參數(shù)的介紹
#-i 指定要轉(zhuǎn)換視頻的源文件
#-s 視頻轉(zhuǎn)換后視頻的分辨率
#-vcodec 視頻轉(zhuǎn)換時使用的編解碼器
#-r 視頻轉(zhuǎn)換換的楨率(默認25楨每秒)
#-b 視頻轉(zhuǎn)換換的bit率
#-ab 音頻轉(zhuǎn)換后的bit率(默認64k)
#-acodec 制度音頻使用的編碼器
#-ac 制定轉(zhuǎn)換后音頻的聲道
#-ar 音頻轉(zhuǎn)換后的采樣率
./ffmpeg -i source.wmv -f psp -r 29.97 -b 768k -ar 24000 -ab 64k -s 320*240 destination.mp4