|
目錄: 1 前言本文說(shuō)描述的選項(xiàng), 不是每個(gè)版本的ffmpeg都具有. 有些選項(xiàng)在不同的版本中有可能會(huì)有不同的名稱或者表述方式. 2 命令選項(xiàng)2.1 通用選項(xiàng)-L license -h 幫助 -formats 顯示可用的文件封裝格式, 編解碼, 協(xié)議等. 其中D為Decode或Demux, E為Encode或者M(jìn)ux. -codecs 相對(duì)于-formats只顯示編解碼格式. -f fmt 強(qiáng)迫采用格式fmt(文件格式, 如wav, avi等). 如果不指定該選項(xiàng), 則使用文件擴(kuò)展名來(lái)自動(dòng)探測(cè)格式. -i filename 輸入文件 -y 覆蓋輸出文件 -t duration 設(shè)置錄制/轉(zhuǎn)碼的時(shí)長(zhǎng). hh:mm:ss[.xxx]格式的記錄時(shí)間也支持 -ss position 搜索到指定的起始時(shí)間 [-]hh:mm:ss[.xxx]的格式也支持 -title string 設(shè)置標(biāo)題(本人編譯的linux版本未帶此選項(xiàng)) -author string 設(shè)置本人(本人編譯的linux版本未帶此選項(xiàng)) -copyright string 設(shè)置版權(quán)(本人編譯的linux版本未帶此選項(xiàng)) -comment string 設(shè)置評(píng)論(本人編譯的linux版本未帶此選項(xiàng)) -target type 設(shè)置目標(biāo)文件類型(type可以為: vcd, svcd, dvd, 'dv', 'dv50')所有的格式選項(xiàng)(比特率, 編解碼以及緩沖區(qū)大小)自動(dòng)設(shè)置, 只需要輸入如下的就可以了: ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg. 另外, type也可以加前綴: 'pal-', 'ntsc-' or 'film-'. -hq 激活高質(zhì)量設(shè)置(本人編譯的linux版本未帶此選項(xiàng)) -itsoffset offset 設(shè)置以秒為基準(zhǔn)的時(shí)間偏移, 該選項(xiàng)影響所有后面的輸入文件. 該偏移被加到輸入文件的時(shí)戳, 定義一個(gè)正偏移意味著相應(yīng)的流被延遲了 offset秒. [-]hh:mm:ss[.xxx]的格式也支持 2.2 視頻選項(xiàng)-b:v bitrate 設(shè)置比特率, 缺省200kb/s(該數(shù)值依據(jù)轉(zhuǎn)發(fā)的文章, 本人未驗(yàn)證). -r fps 設(shè)置幀率. 缺省25(該數(shù)值依據(jù)轉(zhuǎn)發(fā)的文章, 本人未驗(yàn)證) -s size 設(shè)置幀大小 格式為WXH 缺省160X128. 默認(rèn)為與源相同大小. 下面的簡(jiǎn)寫也可以直接使用: Sqcif 128X96 qcif 176X144 cif 252X288 4cif 704X576 -aspect aspect 設(shè)置橫縱比 4:3 16:9 或 1.3333 1.7777 -croptop size 設(shè)置頂部切除帶大小 像素單位 -cropbottom size -cropleft size -cropright size -padtop size 設(shè)置頂部補(bǔ)齊的大小 像素單位 -padbottom size -padleft size -padright size -padcolor color 設(shè)置補(bǔ)齊條顏色(hex,6個(gè)16進(jìn)制的數(shù), 紅:綠:蘭排列, 比如 000000代表黑色) -vn 不做視頻記錄 -bt tolerance 設(shè)置視頻碼率容忍度kbit/s -maxrate bitrate設(shè)置最大視頻碼率容忍度 -minrate bitreate 設(shè)置最小視頻碼率容忍度 -bufsize size 設(shè)置碼率控制緩沖區(qū)大小 -vcodec codec 強(qiáng)制使用codec編解碼方式. 如果用copy表示原始編解碼數(shù)據(jù)必須被拷貝. -sameq 使用同樣視頻質(zhì)量作為源(VBR). -pass n 選擇處理遍數(shù)(1或者2). 兩遍編碼非常有用. 第一遍生成統(tǒng)計(jì)信息, 第二遍生成精確的請(qǐng)求的碼率 -passlogfile file 選擇兩遍的紀(jì)錄文件名為file 2.3 高級(jí)視頻選項(xiàng)-g gop_size 設(shè)置圖像組大小 -intra 僅適用幀內(nèi)編碼 -qscale q 使用固定的視頻量化標(biāo)度(VBR) -qmin q 最小視頻量化標(biāo)度(VBR) -qmax q 最大視頻量化標(biāo)度(VBR) -qdiff q 量化標(biāo)度間最大偏差 (VBR) -qblur blur 視頻量化標(biāo)度柔化(VBR) -qcomp compression 視頻量化標(biāo)度壓縮(VBR) -rc_init_cplx complexity 一遍編碼的初始復(fù)雜度 -b_qfactor factor 在p和b幀間的qp因子 -i_qfactor factor 在p和i幀間的qp因子 -b_qoffset offset 在p和b幀間的qp偏差 -i_qoffset offset 在p和i幀間的qp偏差 -rc_eq equation 設(shè)置碼率控制方程 默認(rèn)tex^qComp -rc_override override 特定間隔下的速率控制重載 -me method 設(shè)置運(yùn)動(dòng)估計(jì)的方法 可用方法有 zero phods log x1 epzs(缺省) full -dct_algo -idct_algo -er n -ec -bf frames 使用frames B 幀, 支持mpeg1,mpeg2,mpeg4 -mbd -4mv 使用4個(gè)運(yùn)動(dòng)矢量 僅用于mpeg4 -part 使用數(shù)據(jù)劃分 僅用于mpeg4 -bug param 繞過(guò)沒(méi)有被自動(dòng)監(jiān)測(cè)到編碼器的問(wèn)題 -strict strictness 跟標(biāo)準(zhǔn)的嚴(yán)格性 -aic 使能高級(jí)幀內(nèi)編碼 h263+ -umv 使能無(wú)限運(yùn)動(dòng)矢量 h263+ -deinterlace 不采用交織方法 -interlace 強(qiáng)迫交織法編碼僅對(duì)mpeg2和mpeg4有效. 當(dāng)你的輸入是交織的并且你想要保持交織以最小圖像損失的時(shí)候采用該選項(xiàng). 可選的方法是不交織, 但是損失更大 -psnr 計(jì)算壓縮幀的psnr -vstats 輸出視頻編碼統(tǒng)計(jì)到vstats_hhmmss.log -vhook module 插入視頻處理模塊 module 包括了模塊名和參數(shù), 用空格分開(kāi) 2.4 音頻選項(xiàng)-ab bitrate 設(shè)置音頻碼率. 有些版本是(-b:a bitrate) -ar freq 設(shè)置音頻采樣率 -ac channels 設(shè)置通道 缺省為與輸入相同. -an 不使能音頻紀(jì)錄 -acodec codec 使用codec編解碼 2.5 音頻/視頻捕獲選項(xiàng)-vd device 設(shè)置視頻捕獲設(shè)備. 比如/dev/video0 -vc channel 設(shè)置視頻捕獲通道 DV1394專用 -tvstd standard 設(shè)置電視標(biāo)準(zhǔn) NTSC PAL(SECAM) -dv1394 設(shè)置DV1394捕獲 -av device 設(shè)置音頻設(shè)備 比如/dev/dsp 2.6 高級(jí)選項(xiàng)-map file:stream 設(shè)置輸入流映射 -debug 打印特定調(diào)試信息 -benchmark 為基準(zhǔn)測(cè)試加入時(shí)間 -hex 傾倒每一個(gè)輸入包 -bitexact 僅使用位精確算法 用于編解碼測(cè)試 -ps size 設(shè)置包大小, 以bits為單位 -re 以本地幀頻讀數(shù)據(jù), 主要用于模擬捕獲設(shè)備 -loop 循環(huán)輸入流(只工作于圖像流, 用于ffserver測(cè)試) 2.7 常用參數(shù)舉例2.7.1 壓縮分辨率ffmpeg -i 1080.mp4 -s 1280x720 720.mp42.7.2 轉(zhuǎn)碼2.7.3 截圖單張 ffmpeg -ss 00:02:00 -i car_1080.mp4 -vframes 1 -y car_1080.pngffmpeg -ss 00:02:00 -i car_1080.mp4 -vframes 1 -y car_1080.jpg說(shuō)明:
連續(xù)多張 說(shuō)明:
2.7.4 添加水印水印局中: ffmpeg -i input.mp4 -i watermark.png -filter_complex overlay='(main_w/2)-(overlay_w/2):(main_h/2)-(overlay_h)/2' center.mp4ffmpeg -i input.mp4 -i watermark.png -filter_complex overlay='5:5' upper_left.mp4說(shuō)明:
2.7.5 設(shè)置264 Profile2.7.6 設(shè)置SAR, DAR命令行: ffmpeg -i infile -vcodec copy -acodec copy -vbsf h264_changesps=arg1arg2[/arg3] outfileargs can be: there are two distinct cases: sar/dar is stored in container - AFAIK this should worksar/dar is stored in bistream - reencode is needed - though one could need to just replace few bits... 2.7.7 設(shè)置幀率
if you want more presice control, not only control fps. but also tbr, tbn, tbc. assume you understand what mean of it. tbc,tbn,tbr. check ffmpeg -x264opts timebase=???or 2.7.8 推送rtmp碼流ffmpeg -re -i ./test.flv -acodec copy -vcodec copy -f flv rtmp://localhost/live/test2.7.9 推送udp碼流如果需要指定udp包大小: ffmpeg -re -i ./test.ts -c copy -f mpegts -y udp://1.2.3.4:12345?pkt_size=13162.7.10 探測(cè)視頻是逐行還是隔行得到如下輸出: [Parsed_idet_0 @ 0x2386bc0] Repeated Fields: Neither: 92 Top: 4 Bottom: 5[Parsed_idet_0 @ 0x2386bc0] Single frame detection: TFF: 101 BFF: 0 Progressive: 0 Undetermined: 0[Parsed_idet_0 @ 0x2386bc0] Multi frame detection: TFF: 101 BFF: 0 Progressive: 0 Undetermined: 0此例檢測(cè)了100幀, 得到TFF: 101, 說(shuō)明是隔行(TFF表示隔行的頂場(chǎng), BFF表示底場(chǎng), Progressive表示逐行的幀). 如果都是Progressive, 則是逐行. 3 參數(shù)詳解3.1 視頻tbn the time base in AVStream that has come from the container. tbn代表文件層(st)的時(shí)間精度. tbc the time base in AVCodecContext for the codec used for a particular stream. tbc代表視頻層( tbr tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate. 代表幀率; 4 ffprobe常用參數(shù)5 參考文獻(xiàn)
Human knowledge belongs to the world |
|
|