小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

ffmpeg命令行參數(shù)中文詳解

 BOBD1997 2019-03-17

目錄:

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 algo 設(shè)置dct的算法 可用的有 0 FF_DCT_AUTO 缺省的DCT 1 FF_DCT_FASTINT 2 FF_DCT_INT 3 FF_DCT_MMX 4 FF_DCT_MLIB 5 FF_DCT_ALTIVEC

-idct_algo algo 設(shè)置idct算法. 可用的有 0 FF_IDCT_AUTO 缺省的IDCT 1 FF_IDCT_INT 2 FF_IDCT_SIMPLE 3 FF_IDCT_SIMPLEMMX 4 FF_IDCT_LIBMPEG2MMX 5 FF_IDCT_PS2 6 FF_IDCT_MLIB 7 FF_IDCT_ARM 8 FF_IDCT_ALTIVEC 9 FF_IDCT_SH4 10 FF_IDCT_SIMPLEARM

-er n 設(shè)置錯(cuò)誤殘留為n 1 FF_ER_CAREFULL 缺省 2 FF_ER_COMPLIANT 3 FF_ER_AGGRESSIVE 4 FF_ER_VERY_AGGRESSIVE

-ec bit_mask 設(shè)置錯(cuò)誤掩蔽為bit_mask,該值為如下值的位掩碼 1 FF_EC_GUESS_MVS (default=enabled) 2 FF_EC_DEBLOCK (default=enabled)

-bf frames 使用frames B 幀, 支持mpeg1,mpeg2,mpeg4

-mbd mode 宏塊決策 0 FF_MB_DECISION_SIMPLE 使用mb_cmp 1 FF_MB_DECISION_BITS 2 FF_MB_DECISION_RD

-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.mp4

2.7.2 轉(zhuǎn)碼

ffmpeg -i h265.ts -vcodec h264 -acodec aac -strict -2 h264.mp4

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ō)明:

  • -ss: 表示要截取的時(shí)間. 注意, 該參數(shù)要放在-i前面, 否則如果截取的時(shí)間點(diǎn)靠后的話會(huì)很慢.

  • -vframes: 表示截取的幀數(shù).

連續(xù)多張

ffmpeg -ss 00:02:00  -i car_1080.mp4  -vframes 20 -r 10 -y b-%3d.png

說(shuō)明:

  • -vframes 20: 表示截取20幀.

  • -r 10: 表示截取的幀率(幀率10, 即一秒鐘的內(nèi)容, 截取為10張圖片). 如果不指定表示按照原視頻的幀率.

  • b-%3d.jpg: 格式化文件命名,會(huì)生成 b-001.jpg,b-002.jpg 等

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ō)明:

  • -i input.mp4: 視頻源

  • -i watermark.png: 水印圖片

  • overlay: 水印的位置

  • center.mp4: 輸出文件

2.7.5 設(shè)置264 Profile

-profile:v baseline -level 3.0-profile:v baseline -level 3.1-profile:v main -level 3.1-profile:v main -level 4.0-profile:v high -level 4.0-profile:v high -level 4.1-profile:v high -level 4.2 

2.7.6 設(shè)置SAR, DAR

命令行:

ffmpeg -i infile -vcodec copy -acodec copy -vbsf h264_changesps=arg1arg2[/arg3] outfile

args can be:

sar=x:y ---- Set sar to x:y, 0:0 will remove sar info

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è)置幀率

ffmpeg -i B.avi -codec:v mpeg4 -r 30 -qscale:v 2 -codec:a copy C.avi
  • -codec:v mpeg4 - Use the encoder called mpeg4 for MPEG-4 Part 2 video.

  • -r 30 - Set output frame rate as 30.

  • -qscale:v 2 - Set video output quality using a constant quantization parameter. Recommended range is 2-5 for mpeg4.

  • -codec:a copy - Copy the audio from input to output to avoid re-encoding.

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

ffmpeg -time_base

2.7.8 推送rtmp碼流

ffmpeg -re -i ./test.flv -acodec copy -vcodec copy -f flv rtmp://localhost/live/test

2.7.9 推送udp碼流

ffmpeg -re -i ./test.ts -c copy -f mpegts -y udp://1.2.3.4:12345

如果需要指定udp包大小:

ffmpeg -re -i ./test.ts -c copy -f mpegts -y udp://1.2.3.4:12345?pkt_size=1316

2.7.10 探測(cè)視頻是逐行還是隔行

ffmpeg -filter:v idet  -frames:v 100  -an -f rawvideo -y /dev/null -i test.ts

得到如下輸出:

[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代表視頻層(st->codec)的時(shí)間精度.

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ù)

-show_data                  show packets data  -show_data_hash             show packets data hash  -show_error                 show probing error  -show_format                show format/container info  -show_frames                show frames info  -show_format_entry entry    show a particular entry from the format/container info  -show_entries entry_list    show a set of specified entries  -show_packets               show packets info  -show_programs              show programs info  -show_streams               show streams info  -show_chapters              show chapters info  -count_frames               count the number of frames per stream  -count_packets              count the number of packets per stream  -show_program_version       show ffprobe version  -show_library_versions      show library versions  -show_versions              show program and library versions  -show_pixel_formats         show pixel format descriptions  -show_private_data          show private data  

5 參考文獻(xiàn)

  • 轉(zhuǎn)自: http://blog.csdn.net/leixiaohua1020/article/details/12751349 并加入本人的解釋.

  • ffmpeg+libx264: https://trac./wiki/Encode/H.264

Human knowledge belongs to the world

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多