ffmpeg編譯及使用 (轉載)

ffmpeg編譯及使用
1 ffmpeg介紹
ffmpeg是音視頻的分離,轉換,編碼解碼及流媒體的完全解決方案,其中最重要的就是libavcodec庫。它被mplayer或者xine使用作爲解碼器。還有,國內比較流行的播放器影音風暴或MyMPC的後端ffdshow也是使用ffmpeg的解碼庫的。
ffmpeg軟件包經編譯過後將生成三個可執行文件,ffmpeg,ffserver,ffplay。其中ffmpeg用於對媒體文件進行處理,ffserver是一個http的流媒體服務器,ffplay是一個基於SDL的簡單播放器。
ffmpeg中有五個庫文件,libavcodec,libavformat,libavutil,libswscale,libpostproc,其中庫libavcodec,libavformat用於對媒體文件進行處理,如格式的轉換;libavutil是一個通用的小型函數庫,該庫中實現了CRC校驗碼的產生,128位整數數學,最大公約數,整數開方,整數取對數,內存分配,大端小端格式的轉換等功能;libswscale,libpostproc暫時不知道何用。
2 ffmpeg下載
最新的ffmpeg可以通過svn下載,SVN輔助的軟件有:
SubVersion,從 http://subversion.tigris.org/ 下載,支持linux。
TortoiseSVN,從 http://tortoisesvn.tigris.org/ 下載,是很不錯的SVN客戶端程序,爲windows外殼程序集成到windows資源管理器和文件管理系統的Subversion客戶端,用起來很方便。
subversion安裝,記住最好之前裝過apr和apr-util,在apache.org網站能下到
wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz
tar zvxf subversion-1.3.2.tar.gz
cd subversion-1.3.2
./configure --with-apr=/usr/local/apr-httpd --with-apr-util=/usr/local/apr-util-httpd/
make
make install
如果安裝了FC6,它已經帶了svn,不用裝了。
ffmpeg的下載:我們就可以通過svn命令獲取最新的ffmpeg,命令如下:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
3 ffmpeg支持庫的安裝
* xvid
xvid的獲取地址如下:
http://www.xvid.org/
wget http://downloads.xvid.org/downloads/xvidcore-1.1.3.tar.gz
配置編譯
   for x86
#./configure --prefix=/usr/local
#make
#make install
   for arm
#CC=arm-linux-gcc ./configure --prefix=/usr/local/arm/arm-linux --build=i686-pc-linux --host=arm-linux --target=arm-linux
#make
#make install
* x264
x264的獲取地址如下:
svn co svn://svn.videolan.org/x264/trunk x264
配置編譯
   for x86
#./configure --enable-shared --prefix=/usr/local
#make
#make install
   for arm
#CC=arm-linux-gcc ./configure --enable-pthread --enable-shared --host=arm-linux
--prefix=/usr/local/arm/arm-linux
#make
#make install
* 支持mp3
lame的獲取地址如下: http://lame.sourceforge.net/index.php
配置編譯
   for x86
./configure --enable-shared --prefix=/usr/local
* 支持Ogg Vorbis:
* AC3和dts編碼的支持
libdts編譯參數
./configure --prefix=/usr
make
make install
* mpg4 aac格式支持,如果ffserver服務器還針對手機用戶服務,所以,類似aac,mpg4鈴聲格式的支持,我們也得做。這裏我們安裝faad2和faac就行,下載請到http://www.audiocoding.com/modules/mydownloads/http://prdownloads.sourceforge.net/faac
   FAAD2的編譯
cd faad2
autoreconf -vif
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
make install
   faac的編譯
cd faac
chmod +x bootstrap
./bootstrap
./configure --prefix=/usr --with-mp4v2 --enable-shared
make
make install
在編譯ffmpeg,在configure時加上--enable-amr_nb --enable-faad --enable-faac參數。
* 支持3gp格式,這也是現在好多手機支持的格式,所以也得支持編譯
編譯的時候加上--enable-amr_nb --enable-amr_wb參數就行,根據編譯系統的提示,所以我們得下載一些編譯3gp所需得文件。
源碼網址:http://www.3gpp.org/ftp/Specs
wget http://www.3gpp.org/ftp/Specs/ar ... 6.204/26204-510.zip
解壓以後把裏面的文件都拷貝到libavcodec/amrwb_float
wget http://www.3gpp.org/ftp/Specs/ar ... 6.104/26104-510.zip
解壓以後把裏面的文件都拷貝到libavcodec/amr_float
* ffmpeg支持VC1格式
    微軟ASF格式的三個版本,WMV1,WMV2,WMV3分別對應MediaPlayer的版本7,8和9,所以很多時候會稱VC1爲WMV3或 WMV9,都是它了,有時候在代碼裏,也能看到稱呼它爲VC9的。因爲微軟還沒有正式公開這種格式,所以當前對VC1的支持還很不完善。本文基本是根據Multimedia Mike的一篇博客翻譯和完善而來。
    (1) 首先要下載 SMPTE VC-1 reference decoder,這個組織是要收費的,可以從這裏下載免費的。
    (2) 在ffmpeg目錄下的libavcodec目錄下面,建立目錄libvc1。
    (3) 將VC1_reference_decoder_release6/decoder/目錄中的*.c和*.h文件全部copy到libvc1目錄下。
    (4) 將VC1_reference_decoder_release6/shared/目錄中的*.c和*.h文件全部copy到libvc1目錄下。
    (5) 將 libvc1-makefile.txt放到libvc1下的Makefile文件。
    (6) 將smpte-vc1.c文件放到libavcodec目錄下。
    (7) 修改libavcodec目錄下的vc9.c,將文件最後的wmv3_decoder這個AVCodec的structure,用#if 0和#endif包含起來,也就是使它失效了。
    (8) 修改libavcodec目錄下的allcodecs.c,將register_avcodec(&wmv3_decoder)上下的註釋去掉,使它發揮作用。
    (9) 修改libavcodec目錄下的Makefile,把OBJS的列表中加入smpte-vc1.o。
    (10)修改ffmpeg主目錄下的Makefile文件,把-L./libavcodec/libvc1 -lvc1$(BUILDSUF)加入到FFLIBS後面。
    (11) 進入ffmpeg/libavcodec/libav1,執行make
    (12) 到ffmpeg主目錄下,執行config;make;make install。config時根據實際情況帶參數。
* 採用ffmpeg轉碼製作FLV文件的方法
    採用ffmpeg轉碼製作FLV文件,和轉碼成其它媒體類型的重要差別是一定要有lame庫支持,因爲FLV的聲音編碼採用mp3格式,非lame這個東東不行。編譯ffmpeg中加入lame庫真是一場災難,特別在windows下,很多參數都不能發揮作用,最後直接手工copy和改一些文件,記錄如下:
    (1) 如果在Windows下編譯,第一步當然是下載MinGW和MSYS來裝上了。到http://mingw.sourceforge.net/去下載最新版的MinGW-5.0.2.exe和MSYS-1.0.11-2004.04.30-1.exe。
    (2) 先安裝MinGW,直接運行MinGW-5.0.2.exe安裝,選擇目錄,譬如選擇D:\MinGW爲安裝目錄。安裝時需要選擇gcc和make模塊,安裝文件本身很小,會從網上下載模塊來安裝。
    (3) 然後安裝MSYS,也是直接運行MSYS-1.0.11-2004.04.30-1.exe安裝。安裝目錄一般選擇D:\MinGW\bin \1.0。,安裝過程會詢問剛纔安裝MinGW的目錄,輸入D:\MinGW,其它都回答'Y'就搞定了。如果不清楚,可以看這個圖片效果。
    (4) 運行MSYS,桌面上有個圖標,雙擊就運行了,運行結果是一個模擬unix的命令窗口,後面的編譯都在這種狀態下進行。前面4步在linux不需要。
    (5) 到http://lame.sourceforge.net/去下載最新版的lame-3.97b2.tar.gz,copy到你認爲合適的地方,解壓後進入lame解壓出來的目錄中。執行
        ./configure --prefix=PREFIX
        make
        make install
    (6) 就把編譯出來的include下的lame目錄copy到/usr/include目錄下,把lib下的幾個庫文件都copy到/usr/lib目錄 下。這裏注意有個變化,如果只copy lib目錄下的靜態庫到/usr/lib下,就是隻copy libmp3lame.a文件,編譯出來的ffmpeg最終就不會對libmp3lame的動態庫有依賴關係,這是因爲編譯首先找動態庫,動態庫沒有才找 靜態庫。如果不做這個copy,後面編譯ffmpeg時無論如何指定參數,都會報錯LAME not found,不知道是哪裏的bug。
    (7) 從http://ffmpeg.mplayerhq.hu/取得最新的ffmpeg,現在自由軟件都大量採用SVN了,要先裝一個SVN,可以去http://tortoisesvn.tigris.org/下載windows版的SVN,去http://subversion.tigris.org/下載linux版的SVN。SVN如何編譯安裝這裏就省略了。
    (8) 如果在windows下,打開解壓後的ffmpeg目錄下的Makefile文件,在FFLIBS的那一行後面加上-lmp3lame$(BUILDSUF)。這個也不知道是哪個bug引起的,搞了好長時間才搞出來,鬱悶。Linux下不用這樣。
4 ffmpeg的編譯
配置編譯
for x86
#./configure --prefix=/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-faadbin --enable-dts --enable-pp --enable-faad --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplay
make
make install
補充1:
關於3gp的編譯,如果大家要編譯--enable-amr_nb-fixed,那就不能跟--enable-amr_nb同時編譯,我不大清楚這兩者到底有什麼區別,似乎
fixed是修正版,管他呢,編譯的方法:
wget http://www.3gpp.org/ftp/Specs/ar ... 6.073/26073-510.zip
解壓以後把裏面的文件都拷貝到libavcodec/amr目錄下
修改libavcodec/amr/makefile 找到CFLAGS = -Wall -pedantic-errors -I. $(CFLAGS_$(MODE)) -D$(VAD) 換成CFLAGS = -Wall -I.
$(CFLAGS_$(MODE)) -D$(VAD) -DMMS_IO
整體編譯參數就是
#./configure --prefix=/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb-fixed --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-dts --enable-pp --enable-faad --enable-faadbin --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplay
make
make install
for x86的簡易配置
#./configure --prefix=./install --disable-shared --enable-pthreads --enable-libx264 --enable-libxvid --arch=i686 --enable-gpl
#make
#make install
for arm
配置編譯
#./configure --prefix=/home/zht/redhatzht/sources/image-colletct/ffmpeg/install --enable-static --disable-shared --enable-libx264 --enable-libxvid --cross-compile --cc=arm-linux-gcc --arch=arm --enable-gpl --disable-strip --disable-network --disable-ipv6 --disable-vhook --disable-audio-beos --disable-audio-oss --disable-mpegaudio-hp  --enable-pthreads --enable-small --disable-parsers --disable-debug
#make
#make install
注意:
(1)“/home/zht/redhatzht/sources/image-colletct/ffmpeg”爲ffmpeg源碼所在目錄。
(2)“/usr/local/arm”爲arm-linux-gcc交叉編譯器所在目錄。
(3) 如果庫文件安裝在/usr/local/lib目錄中導致配置失敗,可以在/etc/ld.so.conf文件中添加/usr/local/lib目錄,然後執行#ldconfig。
    x86上的ldconfig不能在arm上運行,arm上的ldconfig工具是在建立交叉編譯器時,編譯glibc是產生的,可以拷貝到arm-linux中。
(4) 本文大部分內容來自網絡,其中xvid,x264的庫,我親手安裝過,ffmpeg的配置編譯for x86的簡易配置,for arm,我親手配置編譯過,並在x86,arm上可用,編譯配置都是採用靜態庫。
5 ffmpeg用法
ffmpeg作爲媒體文件處理軟件,基本用法如下:
ffmpeg -i INPUTfile [OPTIONS] OUTPUTfile
輸入輸出文件通常就是待處理的多媒體文件了。可以是純粹的音頻文件,純粹的視頻文件,或者混合的。ffmpeg支持絕大部分的常見音頻,視頻格式,象常見的各種mpeg,AVI封裝的DIVX和Xvid等等,具體的格式支持列表可以使用ffmpeg -formats查看或直接查閱文檔。
另外,由於Linux把設備視爲文件,因此-i選項後可以跟設備名。比如DV,視頻卡,光驅或者其它的各類設備。輸出的內容通過
Options調整,其主要的選項如下:
-vcodec  視頻流編碼方式
-b        視頻流碼率(默認只有200k,一般都需要手動設置,具體的數值視codec選擇而定)
-r        視頻流幀數(一般說來PAL制式通常用25,NTSC制式通常用29)
-s         視頻解析度(分辨率,也要視codec和你的需要而定。另:具體寫法使用“數字x數字”的形式)
-t         處理持續時間。
-acodec   音頻流編碼方式
-ab          音頻流碼率(默認是同源文件碼率,也需要視codec而定)
-ar           音頻流採樣率(大多數情況下使用44100和48000,分別對應PAL制式和NTSC制式,根據需要選擇)
-vn  屏蔽視頻流
-an  屏蔽音頻流
-author  設置媒體文件的作者
-title  設置媒體文件的題目
-f  強制使用某種格式
-target type 使用預置的格式轉換(可以轉成dvd,vcd或svcd)
除此之外還有些更高級的選項,如設定vbr,或設定high quality,或者設定vbr的buff和max/min碼率,象一般我們自用的dvd抓軌啦,DV轉vcd dvd啦,網上下載的電影轉成vcd或dvd都不一定需要用到它們。
常用命令選項說明
-fromats 顯示可用的格式
-f fmt 強迫採用格式fmt
-I filename 輸入文件
-y 覆蓋輸出文件
-t duration 設置紀錄時間 hh:mm:ss[.xxx]格式的記錄時間也支持(截圖需要)
-ss position 搜索到指定的時間 [-]hh:mm:ss[.xxx]的格式也支持
-title string 設置標題
-author string 設置作者
-copyright string 設置版權
-comment string 設置評論
-target type 設置目標文件類型(vcd,svcd,dvd),所有的格式選項(比特率,編解碼以及緩衝區大小)自動設置,只需要輸入如下的就可以了:ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
-hq 激活高質量設置
-b bitrate 設置比特率,缺省200kb/s
-r fps 設置幀頻,缺省25
-s size 設置幀大小,格式爲WXH,缺省160X128.下面的簡寫也可以直接使用:Sqcif 128X96 qcif 176X144 cif 252X288 4cif 704X576
-aspect aspect 設置橫縱比 4:3 16:9 或 1.3333 1.7777
-croptop/botton/left/right size 設置頂部切除帶大小,像素單位
-padtop/botton/left/right size 設置頂部補齊的大小,像素單位
-padcolor color 設置補齊條顏色(hex,6個16進制的數,紅:綠:藍排列,比如 000000代表黑色)
-vn 不做視頻記錄
-bt tolerance 設置視頻碼率容忍度kbit/s
-maxrate bitrate設置最大視頻碼率容忍度
-minrate bitreate 設置最小視頻碼率容忍度
-bufsize size 設置碼率控制緩衝區大小
-vcodec codec 強制使用codec編解碼方式. 如果用copy表示原始編解碼數據必須被拷貝.(很重要)
-ab bitrate 設置音頻碼率
-ar freq 設置音頻採樣率
-ac channels 設置通道,缺省爲1
-an 不使能音頻紀錄
-acodec codec 使用codec編解碼
-vd device 設置視頻捕獲設備,比如/dev/video0
-vc channel 設置視頻捕獲通道 DV1394專用
-tvstd standard 設置電視標準 NTSC PAL(SECAM)
-dv1394 設置DV1394捕獲
-av device 設置音頻設備 比如/dev/dsp
-map file:stream 設置輸入流映射
-debug 打印特定調試信息
-benchmark 爲基準測試加入時間
-hex 傾倒每一個輸入包
-bitexact 僅使用位精確算法 用於編解碼測試
-ps size 設置包大小,以bits爲單位
-re 以本地幀頻讀數據,主要用於模擬捕獲設備
-loop 循環輸入流。只工作於圖像流,用於ffserver測試
5 example
(1) ffmpeg的使用
"Video and Audio grabbing"
FFmpeg can use a video4linux compatible video source and any Open Sound System audio source:         
        ffmpeg /tmp/out.mpg
Note that you must activate the right video source and channel before launching ffmpeg. You can use any TV viewer such as
xawtv (<http://bytesex.org/xawtv/>) by Gerd Knorr which I find very good. You must also set correctly the audio recording
levels with a standard mixer.
"Video and Audio file format conversion"
* You can input from YUV files:      
        ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the -s option if ffmpeg cannot guess it.
* You can input from a RAW YUV420P file:         
        ffmpeg -i /tmp/test.yuv /tmp/out.avi
The RAW YUV420P is a file containing RAW YUV planar, for each frame first come the Y plane followed by U and V planes, which are half vertical and horizontal resolution.
* You can output to a RAW YUV420P file:         
        ffmpeg -i mydivx.avi -o hugefile.yuv
* You can set several input files and output files:         
        ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
Convert the audio file a.wav and the raw yuv video file a.yuv to mpeg file a.mpg
* You can also do audio and video conversions at the same time:         
        ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.
* You can encode to several formats at the same time and define a mapping from input stream to output streams:         
        ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. "-map file:index" specify which input stream is used for each output stream, in the order of the definition of output streams.
* You can transcode decrypted VOBs         
        ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
This is a typical DVD ripper example, input from a VOB file, output to an AVI file with MPEG-4 video and MP3 audio, note that in this command we use B frames so the MPEG-4 stream is DivX5 compatible, GOP size is 300 that means an INTRA frame every 10
seconds for 29.97 fps input video.  Also the audio stream is MP3 encoded so you need LAME support which is enabled using --enable-mp3lame when configuring.  The mapping is particularly useful for DVD transcoding to get the desired audio language.
NOTE: to see the supported input formats, use ffmpeg -formats.
(2) ffplay的使用
ffplay - FFplay media player
SYNOPSIS
ffplay [options] input_file
DESCRIPTION
FFplay is a very simple and portable media player using the FFmpeg libraries and the SDL library. It is mostly used as a test bench for the various APIs of FFmpeg.
OPTIONS
"Main options"
show help force displayed width force displayed height disable audio disable video disable graphical display force format
"Advanced options"
show the stream duration, the codec parameters, the current position in the stream, and the audio/video synchronisation drift. force RTP/TCP protocol usage instead of RTP/UDP. It is only meaningful if you are doing stream with the RTSP protocol.
set the master clock to audio ( type=audio), video ( type=video) or external ( type=ext). Default is audio. The master clock is used to control audio-video synchronization. Most media players use audio as master clock, but in some cases (streaming or high quality broadcast) it is necessary to change that. This option is mainly used for debugging purposes.
(3) ffserver的使用
ffsserver - FFserver video server
SYNOPSIS
ffserver [options]
DESCRIPTION
FFserver is a streaming server for both audio and video. It supports several live feeds, streaming from files and time shifting on live feeds (you can seek to positions in the past on each live feed, provided you specify a big enough feed
storage in ffserver.conf).
This documentation covers only the streaming aspects of ffserver / ffmpeg. All questions about parameters for ffmpeg, codec questions, etc. are not covered here. Read ffmpeg-doc.html for more information.
OPTIONS
print the license print the help use configfile instead of /etc/ffserver.conf
6 其他(參考)
(1)mencoder篇
   首先獲取mplayer軟件包極其mplayer官網上自帶的codecs.如果喜歡mplayer,也可以下載gui和font.關於mplayer-1.0rc1在71.21的/home/zhengyu/tools中能找到.如果需要網上下載,可以去官網:http://www.mplayerhq.hu/de...下載rc1地址如
下:http://www1.mplayerhq.hu/M...最新的svn版本:http://www1.mplayerhq.hu/M...官網同時也給出了一些codec,其中就有rm格式的codec:http://www1.mplayerhq.hu/M...    xplore也提供下載,mplayer1.0rc1下載,codec下載.
   下載完成之後,將tar vxjf essential-20061022.tar.bz2;sudo mkdir -p /usr/lib/codecs;sudo cp -rf essential-20061022/*
/usr/lib/codecs;然後解包mplayer,按如下方式編譯:
./configure --prefix=/usr/local --enable-gui --enable-largefiles  --enable-gif --enable-png --enable-jpeg --language=zh_CN --with-codecsdir=/usr/lib/codecs/
make
(sudo make install)
   然後就可以使用mencoder,當然也有一個沒有gui的mplayer可以播放各種視頻了.不過我們需要的是mencoder.至此,ffmpeg+mencoder搭建完成.
(2) 常見操作說明
對於ffmpeg,可以將除swf,rmvb,wmav9以外的視頻/音頻格式轉換成flv/mp3,同時可以截取這些視頻文件中的某個時間的該幀圖片.這些實際上就是一個視頻播客顯示的部分.對於mencoder,支持各種常見格式的視頻/音頻轉換成flv/mp3.或者轉換成avi.
1) ffmpeg進行操作的常用方法:
   * 轉換成flv文件:ffmpeg -i infile.* -y (-ss second_offset -ar ar -ab ab -r vr -b vb -s vsize) outfile.flv
        其中second_offset是從開始的多好秒鐘.可以支持**:**:**格式,至於ar,ab是音頻的參數,可以指定ar= 22050,24000,44100(PAL制式),48000(NTSC制式),後兩種常見,ab=56(視音頻協議的codec而定,如果要聽高品質,則80以上).vr,vb,vsize是視頻參數,可以指定vr=15,25(PAL),29(NTSC),vb=200,500,800,1500 (視視頻協議的codec而定,可以通過查看專業的codec說明文檔獲取,如果你手頭有一份詳細的各種codec的文檔,請提供一份給我,不勝感激.),還有一些參數-acodec ac -vcodec vc(ac指定音頻codec,ar和ab可以省去,vc指定視頻codec,vr和vb可以省去,自動採用相應的codec參數)還有很多高級參數,如-qmin,-qcale等,請查看詳細文檔。還有-an和-vn參數,分別從多媒體文件中提取出純粹視頻和音頻。另,如果你是用shell批量處理,請使用-y參數覆蓋生成flv.
   * 截取圖片:ffmpeg -i infile.* -y (-ss second_offset) -t 0.001 -s msize (-f image_fmt) outfile.jpg
            其中second_offset同上,msize同vsize,圖片大小.image_fmt=image2強制使用jpg,image_fmt=gif,強制使用gif格式.還可以用-vframes fn指定截取某幀圖片,fn=1,2,3,...
2)mencoder操作
    mencoder的作用主要在視頻轉碼方面.在安裝完mplayer後,mencoder也編譯生成了.可以man mencoder獲取mencoder的說明文檔. mencoder的參數更加複雜,不過也無非是音頻處理視頻處理兩個方面,可以參看網絡例子:http://www.masoncn.com/pos...這裏不作詳細的列舉了.
   mencoder進行操作的常用方法: mencoder infile.* -o outfile.* [-ovc 目標視頻格式] [-oac 目標音頻格式] [-of 目標文件格式]
   * 轉換成flv文件: mencoder infile.* -o outfile.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts
vcodec=flv:vbitrate=150:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050
   * 轉換成avi文件: mencoder infile.* -o outfile.avi -of avi -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts
bitrate=600
   * 轉換成wmv文件(複雜寫法,其中高級參數可以省去): mencoder infile.* -o outfile.wmv -of lavf -ofps 25 -oac mp3lame -lameopts
cbr:preset=128 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=768:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=320:240 -srate
22050 -sws 9 -subcp cp936 -subpos 0 -subalign 0 -subfont-text-scale 3 -lavfopts i_certify_that_my_video_strea
   其中-ovc,-oac和-of是必須的,-ovc是指定視頻codec,指定了ovc之後通常帶一個該codec的opt參數,-oac是指定音頻 codec,也會在其後帶一個codec的opt參數.可以指定細節以決定視頻音頻質量和轉換速率.具體的細節可以參看專業的技術文檔.
7  ffmpeg配置選項
[root@web ffmpeg]# ./configure --help
Usage: configure [options]
Options: [defaults in brackets after descriptions]
Standard options:   基本選項參數
  --help                   顯示此幫助信息|print this message
  --log[=FILE|yes|no]      記錄測試並輸出到config.err文件|log tests and output to FILE [config.err]
  --prefix=PREFIX          安裝程序到指定目錄(默認/usr/local)|install in PREFIX [/usr/local]
  --libdir=DIR             安裝庫到指定目錄(默認prefix/lib)|install libs in DIR [PREFIX/lib]
  --shlibdir=DIR           指定共享庫路徑(默認prefix/lib)|install shared libs in DIR [PREFIX/lib]
  --incdir=DIR             指定includes路徑(默認prefix/include/ffmpeg)|install includes in DIR[PREFIX/include/ffmpeg]
  --mandir=DIR             指定man page路徑(默認prefix/man)install man page in DIR [PREFIX/man]
  --enable-mp3lame         啓用mp3編碼libmp3lame(默認關閉)enable MP3 encoding via libmp3lame[default=no]
  --enable-libogg          啓用ogg支持libogg(默認關閉)enable Ogg support via libogg [default=no]
  --enable-vorbis          啓用Vorbis支持libvorbis(默認關閉)enable Vorbis support via libvorbis [default=no]
  --enable-faad            啓用faad支持libfaad(默認關閉)enable FAAD support via libfaad [default=no]
  --enable-faadbin         啓用faad運行時鏈接支持(默認關閉)build FAAD support with runtime linking[default=no]
  --enable-faac            啓用faac支持libfaac(默認關閉)enable FAAC support via libfaac [default=no]
  --enable-libgsm          啓用GSM支持libgsm(默認關閉)enable GSM support via libgsm [default=no]
  --enable-xvid            啓用xvid支持xvidcore(默認關閉)enable XviD support via xvidcore [default=no]
  --enable-x264            啓用H.264編碼(默認關閉)enable H.264 encoding via x264 [default=no]
  --enable-mingw32         啓用MinGW本地/交叉win環境編譯|enable MinGW native/cross Windows compile
  --enable-mingwce         啓用MinGW本地/交叉winCE環境編譯enable MinGW native/cross WinCE compile
  --enable-a52             啓用A52支持(默認關閉)enable GPLed A52 support [default=no]
  --enable-a52bin          啓用運行時打開liba52.so.0(默認關閉)open liba52.so.0 at runtime [default=no]
  --enable-dts             啓用DTS支持(默認關閉)enable GPLed DTS support [default=no]
  --enable-pp              啓用後加工支持(默認關閉)enable GPLed postprocessing support [default=no]
  --enable-static          構建靜態庫(默認啓用)build static libraries [default=yes]
  --disable-static         禁止構建靜態庫(默認關閉)do not build static libraries [default=no]
  --enable-shared          構建共享庫(默認關閉)build shared libraries [default=no]
  --disable-shared         禁止構建共享庫(默認啓用)do not build shared libraries [default=yes]
  --enable-amr_nb          啓用amr_nb float音頻編解碼器|enable amr_nb float audio codec
  --enable-amr_nb-fixed    啓用fixed amr_nb codec | use fixed point for amr-nb codec
  --enable-amr_wb          啓用amr_wb float音頻編解碼器|enable amr_wb float audio codec
  --enable-amr_if2         啓用amr_wb IF2音頻編解碼器|enable amr_wb IF2 audio codec
  --enable-sunmlib         啓用Sun medialib(默認關閉) | use Sun medialib [default=no]
  --enable-pthreads        啓用pthreads(多線程)(默認關閉)use pthreads [default=no]
  --enable-dc1394          啓用libdc1394、libraw1394抓取IIDC-1394(默認關閉)enable IIDC-1394 grabbing using libdc1394 and
libraw1394 [default=no]
  --enable-swscaler        啓用計數器支持?(默認關閉)software scaler support [default=no]
  --enable-avisynth        允許讀取AVISynth腳本本件(默認關閉)allow reading AVISynth script files [default=no]
  --enable-gpl             允許使用GPL(默認關閉)allow use of GPL code, the resulting libav* and ffmpeg will be under GPL
[default=no]
Advanced options (experts only): 高級選項參數(供專業人員使用)
  --source-path=PATH       源碼的路徑(當前爲/root/flv/ffmpeg)| path to source code [/root/flv/ffmpeg]
  --cross-prefix=PREFIX    爲編譯工具指定路徑 | use PREFIX for compilation tools []
  --cross-compile          假定使用了交叉編譯 | assume a cross-compiler is used
  --cc=CC                  指定使用何種C編譯器(默認gcc)use C compiler CC [gcc]
  --make=MAKE              使用特定的make | use specified make [make]
  --extra-cflags=ECFLAGS   添加ECFLAGS到CFLAGS | add ECFLAGS to CFLAGS []
  --extra-ldflags=ELDFLAGS 添加ELDFLAGS到LDFLAGS(默認-Wl,--as-needed)| add ELDFLAGS to LDFLAGS [ -Wl,--as-needed]
  --extra-libs=ELIBS       添加ELIBS | add ELIBS []
  --build-suffix=SUFFIX    爲專用程序添加後綴 | suffix for application specific build []
  --arch=ARCH              選擇機器架構(默認x86)select architecture  [x86]
  --cpu=CPU                選用最低的cpu(影響指令的選擇,可以在老CPU上出錯) | selects the minimum cpu required (affects
instruction selection, may crash on older CPUs)
  --powerpc-perf-enable    啓用PPC上面的性能報告(需要啓用PMC)enable performance report on PPC
                           (requires enabling PMC)
  --disable-mmx            禁用MMX | disable MMX usage
  --disable-armv5te        禁用armv5te | disable armv5te usage
  --disable-iwmmxt         禁用iwmmxt | disable iwmmxt usage
  --disable-altivec        禁用AltiVec | disable AltiVec usage
  --disable-audio-oss      禁用OSS音頻支持(默認啓用)disable OSS audio support [default=no]
  --disable-audio-beos     禁用BeOS音頻支持(默認啓用)disable BeOS audio support [default=no]
  --disable-v4l            禁用video4linux提取(默認啓用)disable video4linux grabbing [default=no]
  --disable-v4l2           禁用video4linux2提取(默認啓用)disable video4linux2 grabbing [default=no]
  --disable-bktr           禁用bktr視頻提取(默認啓用)disable bktr video grabbing [default=no]
  --disable-dv1394         禁用DV1394提取(默認啓用)disable DV1394 grabbing [default=no]
  --disable-network        禁用網絡支持(默認支持)disable network support [default=no]
  --disable-ipv6           禁用ipv6支持(默認支持)disable ipv6 support [default=no]
  --disable-zlib           禁用zlib(默認支持)disable zlib [default=no]
  --disable-simple_idct    禁用simple IDCT例程(默認啓用)disable simple IDCT routines [default=no]
  --disable-vhook          禁用video hooking支持 | disable video hooking support
  --enable-gprof           enable profiling with gprof [no]
  --disable-debug          禁用調試符號 | disable debugging symbols
  --disable-opts           禁用編譯器最優化 | disable compiler optimizations
  --disable-mpegaudio-hp   啓用更快的解碼MPEG音頻(但精確度較低)(默認禁用)faster (but less accurate) MPEG audio decoding
[default=no]
  --disable-protocols      禁用 I/O 協議支持(默認啓用)disable I/O protocols support [default=no]
  --disable-ffserver       禁用生成ffserver | disable ffserver build
  --disable-ffplay         禁用生成ffplay | disable ffplay build
  --enable-small           啓用優化文件尺寸大小(犧牲速度)optimize for size instead of speed
  --enable-memalign-hack   啓用模擬內存排列,由內存調試器干涉? | emulate memalign, interferes with memory debuggers
  --disable-strip          禁用剝離可執行程序和共享庫 | disable stripping of executables and shared libraries
  --disable-encoder=NAME   禁用XX編碼器 | disables encoder NAME
  --enable-encoder=NAME    啓用XX編碼器 | enables encoder NAME
  --disable-decoder=NAME   禁用XX解碼器 | disables decoder NAME
  --enable-decoder=NAME    啓用XX解碼器 | enables decoder NAME
  --disable-encoders       禁用所有編碼器 | disables all encoders
  --disable-decoders       禁用所有解碼器 | disables all decoders
  --disable-muxer=NAME     禁用XX混音器 | disables muxer NAME
  --enable-muxer=NAME      啓用XX混音器 | enables muxer NAME
  --disable-muxers         禁用所有混音器 | disables all muxers
  --disable-demuxer=NAME   禁用XX解軌器 | disables demuxer NAME
  --enable-demuxer=NAME    啓用XX解軌器 | enables demuxer NAME
  --disable-demuxers       禁用所有解軌器 | disables all demuxers
  --enable-parser=NAME     啓用XX剖析器 | enables parser NAME
  --disable-parser=NAME    禁用XX剖析器 | disables parser NAME
  --disable-parsers        禁用所有剖析器 | disables all parsers
8 參考資料
ffmpeg的編譯大全
ffmpeg的使用
ffmpeg_mencoder環境搭建和視頻處理總結
自譯的ffmpeg ./configure參數<!--++ plugin_code qcomic begin-->

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章