NALU格式

音視頻編碼在流媒體和網(wǎng)絡(luò)領(lǐng)域占有重要地位扳剿;流媒體編解碼流程大致如下圖所示:

image

x264原理解析

參考鏈接: x264百度詞條;H264基本原理;

H264簡介

H.264從1999年開始,到2003年形成草案愿棋,最后在2007年定稿有待核實煞檩。在ITU的標(biāo)準(zhǔn)里稱為H.264腕扶,在MPEG的標(biāo)準(zhǔn)里是MPEG-4的一個組成部分–MPEG-4 Part 10,又叫Advanced Video Codec荠藤,因此常常稱為MPEG-4 AVC或直接叫AVC。x264主要使用算法為H264編解碼算法获高,下面對H264算法進行解析哈肖;

H264 編解碼解析

參考鏈接: H264 編解碼協(xié)議詳解;深入淺出理解視頻編碼H264結(jié)構(gòu);詳細文檔;H264編解碼框圖;

H264編碼原理:

在音視頻傳輸過程中,視頻文件的傳輸是一個極大的問題谋减;一段分辨率為19201080,幀率是25的視頻牡彻,對于傳輸帶寬的要求是:1920108025/8/1024/1024=6.179MB,意味著視頻每秒帶寬為6.179MB這基本是不肯能的蔫耽。因此視頻壓縮和編碼技術(shù)應(yīng)運而生帆吻。
對于視頻文件來說尤揣,視頻由單張圖片幀所組成酪穿,每秒25/32幀鞭缭,但是圖片幀的像素塊之間存在相似性泉粉,因此視頻幀圖像可以進行圖像壓縮跟束;H264采用了16
16的分塊大小對抵窒,視頻幀圖像進行相似比較和壓縮編碼渐行。如下圖所示:

image

除此之外轰坊,對于一段連續(xù)的幀圖像來說,前一幀和后一幀之間的關(guān)聯(lián)度和相似性很高祟印,只記錄當(dāng)前幀和下一幀與當(dāng)前幀之間的幀數(shù)據(jù)差肴沫,能夠快速的幫助我們實現(xiàn)視頻壓縮編解碼。為了方便圖像之間的壓縮蕴忆,將原圖像當(dāng)前幀設(shè)置為Fn,下一幀設(shè)置為Fn-1颤芬;對Fn進行幀內(nèi)相似壓縮編碼,使用估計函數(shù)進行重新映射(圖像還原);再利用當(dāng)前幀對圖和幀差信息對下一幀圖片進行估計和還原套鹅。具體編碼框架如下圖:

image

在上圖中站蝠,輸入的幀或場Fn以宏塊為單位被編碼器處理。首先卓鹿,按幀內(nèi)或者幀間預(yù)測編碼的方法進行處理菱魔。假設(shè)採用幀間預(yù)測編碼,其預(yù)測值PRED是由當(dāng)前片中前面已編碼的參考圖像經(jīng)運動補償(MC)后得到吟孙,當(dāng)中參考圖像用F’n-1表示澜倦。預(yù)測值PRED和當(dāng)前塊相減后,產(chǎn)生一個殘差塊Dn拔疚,經(jīng)塊變換肥隆、量化后產(chǎn)生一組量化后的變換系數(shù)X,再經(jīng)熵編碼稚失,與解碼所需的一些頭信息一起組成壓縮后的碼流栋艳,經(jīng)NAL(網(wǎng)絡(luò)自適應(yīng)層)供傳輸和存儲用。

在進行編碼過后H264也提供了相應(yīng)的解碼方式句各,解碼流程如下圖:

image

將編碼器的NAL輸出的H264比特流經(jīng)熵解碼得到量化后的一組變換系數(shù)X吸占,再經(jīng)反量化、反變換凿宾,得到殘差D’n矾屯。利用從該比特流中解碼出的頭信息,解碼器就產(chǎn)生一個預(yù)測塊PRED初厚,它和編碼器中的原始PRED是同樣的件蚕。當(dāng)該解碼器產(chǎn)生的PRED與殘差D’n相加后孙技,就得到了uF’n,再經(jīng)濾波后排作,最后就得到濾波后的解碼輸出圖像F’n

H264中的I幀牵啦、P幀和B幀

正如上文所說;H264除了使用幀內(nèi)壓縮之外,還使用了幀間壓縮妄痪;H264采用了獨特的I幀哈雏、P幀和B幀策略來實現(xiàn),連續(xù)幀之間的壓縮衫生;

[圖片上傳失敗...(image-381d84-1564739618983)]

如上圖所示裳瘪;

  • I幀:自身可以通過視頻解壓算法解壓成一張單獨的完整的圖片。
  • P幀:需要參考前面的I幀或P幀,還原成完整的圖片罪针。
  • B幀:需要同時參考前面和后面的I幀或P幀,來實現(xiàn)圖片的還原彭羹。
    H.264基準(zhǔn)類中,僅使用I幀和P幀以實現(xiàn)低延時泪酱,因此是網(wǎng)絡(luò)攝像機和視頻編碼器的理想選擇皆怕。
    注意:每當(dāng)讀取到一個新的I幀時,解碼器會更新殘差信息西篓,刪除之前的東西,防止錯誤憋活。

H264編碼結(jié)構(gòu)解析

H264除了實現(xiàn)了對視頻的壓縮處理之外岂津,為了方便網(wǎng)絡(luò)傳輸,提供了對應(yīng)的視頻編碼和分片策略悦即;類似于網(wǎng)絡(luò)數(shù)據(jù)封裝成IP幀吮成,在H264中將其稱為組(gop)、片(slice)辜梳、宏塊(Macroblock)這些一起組成了H264的碼流分層結(jié)構(gòu);H264將其組織成為序列(GOP)粱甫、圖片(pictrue)、片(Slice)作瞄、宏塊(Macroblock)茶宵、子塊(subblock)五個層次。

image

H264將視頻分為連續(xù)的幀進行傳輸宗挥,在連續(xù)的幀之間使用I幀乌庶、P幀和B幀。同時對于幀內(nèi)而言契耿,將圖像分塊為片瞒大、宏塊和字塊進行分片傳輸;通過這個過程實現(xiàn)對視頻文件的壓縮包裝搪桂。

image

在進行H264分包策略解析之前透敌,我們需要先來了解一下H264的原始碼流結(jié)構(gòu)

H264 網(wǎng)絡(luò)包

參考鏈接: 從零了解H264結(jié)構(gòu);H264碼流結(jié)構(gòu)分析;

H264在提出視頻分片壓縮策略的同時,也提出了網(wǎng)絡(luò)分包發(fā)送策略。其詳細分包發(fā)送策略如下:

image

下面我們從網(wǎng)絡(luò)分包的角度對H264原始碼流進行分析酗电;

H.264原始碼流(裸流)是由一個接一個NALU組成魄藕,它的功能分為兩層,VCL(視頻編碼層)和 NAL(網(wǎng)絡(luò)提取層)顾瞻;

  1. VCL:包括核心壓縮引擎和塊泼疑,宏塊和片的語法級別定義,設(shè)計目標(biāo)是盡可能地獨立于網(wǎng)絡(luò)進行高效的編碼荷荤;
  2. NAL:負(fù)責(zé)將VCL產(chǎn)生的比特字符串適配到各種各樣的網(wǎng)絡(luò)和多元環(huán)境中退渗,覆蓋了所有片級以上的語法級別。

在VCL進行數(shù)據(jù)傳輸或存儲之前蕴纳,這些編碼的VCL數(shù)據(jù)会油,被映射或封裝進NAL單元。(NALU)

一個NALU = 一組對應(yīng)于視頻編碼的NALU頭部信息 + 一個原始字節(jié)序列負(fù)荷(RBSP,Raw Byte Sequence Payload).

NALU結(jié)構(gòu)單元的主體結(jié)構(gòu)如下所示古毛;一個原始的H.264 NALU單元常由[StartCode] [NALU Header] [NALU Payload]三部分組成翻翩,其中 Start Code 用于標(biāo)示這是一個NALU 單元的開始,必須是"00 00 00 01" 或"00 00 01"稻薇,除此之外基本相當(dāng)于一個NAL header + RBSP;

[圖片上傳失敗...(image-278870-1564739618983)]

NAL Header

由三部分組成嫂冻,forbidden_bit(1bit),nal_reference_bit(2bits)(優(yōu)先級)塞椎,nal_unit_type(5bits)(類型)

[圖片上傳失敗...(image-7f0e7f-1564739618983)]

image
image

舉例如下:

00 00 00 01 06:  SEI信息   
00 00 00 01 67:  0x67&0x1f = 0x07 :SPS
00 00 00 01 68:  0x68&0x1f = 0x08 :PPS
00 00 00 01 65:  0x65&0x1f = 0x05: IDR Slice

NAL解碼流程如下圖

image
RBSP

NALU主體為RBSP桨仿;RBSP的主要結(jié)構(gòu)如下:

[圖片上傳失敗...(image-31d2b9-1564739618983)]

[圖片上傳失敗...(image-7b427c-1564739618983)]

注意:SODB是RBSP的原始幀

  • SODB 數(shù)據(jù)比特串 -> 是編碼后的原始數(shù)據(jù)
  • RBSP 原始字節(jié)序列載荷 -> 在原始編碼數(shù)據(jù)的后面添加了 結(jié)尾比特。一個 bit“1”若干比特“0”案狠,以便字節(jié)對齊服傍。
    [圖片上傳失敗...(image-d6e30a-1564739618981)]
再解H264中的分包策略

正如圖3所示,NALU主體中包含了片頭和片上數(shù)據(jù)


1幀 = n個片
1片 = n個宏塊
1宏塊 = 16x16yuv數(shù)據(jù)

片是H.264提出的新概念骂铁,通過編碼圖片后切分通過高效的方式整合出來的概念吹零。一張圖片有一個或者多個片,而片由NALU裝載并進行網(wǎng)絡(luò)傳輸?shù)睦帧5荖ALU不一定是切片灿椅,這是充分不必要條件,因為 NALU 還有可能裝載著其他用作描述視頻的信息;片的種類如下表所示

意義
I 片 只包含I宏塊
P 片 包含P和I宏塊
B 片 包含B和I宏塊
SP 片 包含P 和/或 I宏塊,用于不同碼流之間的切換
SI 片 一種特殊類型的編碼宏塊

宏塊是視頻信息的主要承載者名段。一個編碼圖像通常劃分為多個宏塊組成.包含著每一個像素的亮度和色度信息阱扬。視頻解碼最主要的工作則是提供高效的方式從碼流中獲得宏塊中像素陣列。

一個宏塊 = 一個16*16的亮度像素 + 一個8×8Cb + 一個8×8Cr彩色像素塊組成伸辟。(YCbCr 是屬于 YUV 家族的一員,在YCbCr 中 Y 是指亮度分量麻惶,Cb 指藍色色度分量,而 Cr 指紅色色度分量)

宏塊分類 意義
I 宏塊 利用從當(dāng)前片中已解碼的像素作為參考進行幀內(nèi)預(yù)測
P 宏塊 利用前面已編碼圖像作為參考進行幀內(nèi)預(yù)測信夫,一個幀內(nèi)編碼的宏塊可進一步作宏塊的分割:即16×16.16×8.8×16.8×8亮度像素塊窃蹋。如果選了8×8的子宏塊卡啰,則可再分成各種子宏塊的分割,其尺寸為8×8警没,8×4匈辱,4×8,4×4
B 宏塊 利用雙向的參考圖像(當(dāng)前和未來的已編碼圖像幀)進行幀內(nèi)預(yù)測

句法元素的分層結(jié)構(gòu)有助于更有效地節(jié)省碼流杀迹。例如亡脸,再一個圖像中,經(jīng)常會在各個片之間有相同的數(shù)據(jù)树酪,如果每個片都同時攜帶這些數(shù)據(jù)浅碾,勢必會造成碼流的浪費。更為有效的做法是將該圖像的公共信息抽取出來续语,形成圖像一級的句法元素垂谢,而在片級只攜帶該片自身獨有的句法元素。

image
image
宏塊分類 意義
mb_type 確定該 MB 是幀內(nèi)或幀間(P 或 B)編碼模式疮茄,確定該 MB 分割的尺寸
mb_pred 確定幀內(nèi)預(yù)測模式(幀內(nèi)宏塊)確定表 0 或表 1 參考圖 像滥朱,和每一宏塊分割的差分編碼的運動矢量(幀間宏塊,除 8×8 宏塊分割的幀內(nèi) MB)
sub_mb_pred (只對 8×8MB 分割的幀內(nèi) MB)確定每一子宏塊的子宏 塊分割力试,每一宏塊分割的表 0 和/或表 1 的參考圖象;每一 宏塊子分割的差分編碼運動矢量徙邻。
coded_block_pattern 指出哪個 8×8 塊(亮度和彩色)包 編碼變換系數(shù)
mb_qp_delta 量化參數(shù)的改變值
residual 預(yù)測后對應(yīng)于殘差圖象取樣的編碼變換系數(shù)
I,P,B幀與pts/dts
幀的分類 中文 意義
I幀 幀內(nèi)編碼幀,又稱intra picture I 幀通常是每個 GOP(MPEG 所使用的一種視頻壓縮技術(shù))的第一個幀,經(jīng)過適度地壓縮畸裳,做為隨機訪問的參考點鹃栽,可以當(dāng)成圖象。I幀可以看成是一個圖像經(jīng)過壓縮后的產(chǎn)物
P幀 前向預(yù)測編碼幀,又稱predictive-frame 通過充分將低于圖像序列中前面已編碼幀的時間冗余信息來壓縮傳輸數(shù)據(jù)量的編碼圖像躯畴,也叫預(yù)測幀
B幀 雙向預(yù)測幀,又稱bi-directional interpolated prediction frame 既考慮與源圖像序列前面已編碼幀,也顧及源圖像序列后面已編碼幀之間的時間冗余信息來壓縮傳輸數(shù)據(jù)量的編碼圖像,也叫雙向預(yù)測幀

I,P,B幀的不同

  • I frame:自身可以通過視頻解壓算法解壓成一張單獨的完整的圖片薇芝。
  • P frame:需要參考其前面的一個I frame 或者B frame來生成一張完整的圖片蓬抄。
  • B frame:則要參考其前一個I或者P幀及其后面的一個P幀來生成一張完整的圖片。

pts/dts

名稱 意義
PTS(Presentation Time Stamp) PTS主要用于度量解碼后的視頻幀什么時候被顯示出來夯到。
DTS(Decode Time Stamp) DTS主要是標(biāo)識內(nèi)存中的bit流再什么時候開始送入解碼器中進行解碼嚷缭。
image

主要區(qū)別:DTS主要用戶視頻的解碼,在解碼階段使用耍贾。PTS主要用于視頻的同步和輸出阅爽,在display的時候使用。再沒有B frame的時候輸出順序一樣荐开。

IDR
一個序列的第一個圖像叫做 IDR 圖像(立即刷新圖像)付翁,IDR 圖像都是 I 幀圖像。
I和IDR幀都使用幀內(nèi)預(yù)測晃听。I幀不用參考任何幀百侧,但是之后的P幀和B幀是有可能參考這個I幀之前的幀的砰识。IDR就不允許這樣。
其核心作用是佣渴,是為了解碼的重同步辫狼,當(dāng)解碼器解碼到 IDR 圖像時,立即將參考幀隊列清空辛润,將已解碼的數(shù)據(jù)全部輸出或拋棄膨处,重新查找參數(shù)集,開始一個新的序列砂竖。這樣真椿,如果前一個序列出現(xiàn)重大錯誤,在這里可以獲得重新同步的機會晦溪。IDR圖像之后的圖像永遠不會使用IDR之前的圖像的數(shù)據(jù)來解碼瀑粥。

幀(frame)和場(filed)

參考鏈接: 幀編碼與場編碼的區(qū)別分析

視頻的一場和一幀用來產(chǎn)生一個編碼圖像,一幀通常是一個完整的圖像三圆,當(dāng)采集視頻信號時狞换,如果采用隔行掃描(奇、偶數(shù)行)舟肉,則掃描下來的一幀圖像就被分成了兩個部分修噪,這每一部分都被稱為 [場],根據(jù)次序路媚,分為 [頂場] 和 [底場]黄琼。
人眼可察覺到的電視視頻圖像刷新中的閃爍為 0.02 秒,即當(dāng)電視系統(tǒng)的幀率低于 50 幀/秒整慎,人眼可感覺得出畫面的閃爍脏款。常規(guī)如 PAL 制式電視系統(tǒng)幀率為 25 幀/秒、NTSC 制式的則為 30 幀/秒裤园,如果采用逐行掃描將不可避免地在視頻刷新時產(chǎn)生閃爍現(xiàn)象撤师。而另一方面如果單純的提高幀率達到避免閃爍刷新效果,則會增加系統(tǒng)的頻帶寬度拧揽。
隔行掃描中剃盾,每一幀包含兩個場(top field)和(bottom field),其中每個 field 包含一幀中一半數(shù)量的水平線淤袜,top field 包含所有奇數(shù)線痒谴,bottom field 則包含所有偶數(shù)線。則在電視顯示過程中铡羡,電子槍每發(fā)射一行隔一行—先發(fā)射奇數(shù)行13579…(top field)回頭再發(fā)射2468…(bottom field)利用兩次掃描來完成一幅圖像积蔚,因為視覺的滯留性,我們看到的效果是差不多的烦周。如在 NTSC 視頻中 frame 的頻率為30次/秒-àfield的頻率則為 60 次/秒库倘,大于了人眼可察覺閃爍的頻率临扮。

方式 作用域
幀編碼方式 活動量較小或者靜止的圖像宜采用
場編碼方式 活動量較大的運動圖像
image

H264編解碼編程

參考鏈接: x264源代碼簡單分析:概述;
開源的H264編碼器有很多,JMVC教翩,T264杆勇、X264,這里選擇X264饱亿,因為網(wǎng)上關(guān)于X264源碼分析資源很多蚜退。X264編碼器是一個開源的經(jīng)過優(yōu)化的高性能H.264編碼器,目前最新的源碼在本人的I5處理器的PC機上彪笼,編碼1920x1080分辨率的視頻序列在使用ultrafast配置的情況下钻注,可以實現(xiàn)160fps左右的編碼速度。
H264編碼規(guī)范配猫,已經(jīng)有了不錯的編解碼實現(xiàn)幅恋;其中承擔(dān)編碼任務(wù)的主要實現(xiàn)有:x264,解碼主要實現(xiàn)有l(wèi)ibavcodec;下面分別對這兩個進行介紹泵肄。

x264說明和API詳解

x264命令行使用和參數(shù)解析

參考鏈接: X264 01 命令行用法
使用linux 中使用x264時可以直接使用:

x264 --fullhelp //

查看x264幫助信息捆交;顯示內(nèi)容如下


x264 core:148 r2643 5c65704
Syntax: x264 [options] -o outfile infile

Infile can be raw (in which case resolution is required),
  or YUV4MPEG (*.y4m),
  or Avisynth if compiled with support (yes).
  or libav* formats if compiled with lavf support (yes) or ffms support (yes).
Outfile type is selected by filename:
 .264 -> Raw bytestream
 .mkv -> Matroska
 .flv -> Flash Video
 .mp4 -> MP4 if compiled with GPAC or L-SMASH support (gpac)
Output bit depth: 8 (configured at compile time)

Options:

  -h, --help                  List basic options
      --longhelp              List more options
      --fullhelp              List all options

Example usage:

      Constant quality mode:
            x264 --crf 24 -o <output> <input>

      Two-pass with a bitrate of 1000kbps:
            x264 --pass 1 --bitrate 1000 -o <output> <input>
            x264 --pass 2 --bitrate 1000 -o <output> <input>

      Lossless:
            x264 --qp 0 -o <output> <input>

      Maximum PSNR at the cost of speed and visual quality:
            x264 --preset placebo --tune psnr -o <output> <input>

      Constant bitrate at 1000kbps with a 2 second-buffer:
            x264 --vbv-bufsize 2000 --bitrate 1000 -o <output> <input>

Presets:

      --profile <string>      Force the limits of an H.264 profile
                                  Overrides all settings.
                                  - baseline:
                                    --no-8x8dct --bframes 0 --no-cabac
                                    --cqm flat --weightp 0
                                    No interlaced.
                                    No lossless.
                                  - main:
                                    --no-8x8dct --cqm flat
                                    No lossless.
                                  - high:
                                    No lossless.
                                  - high10:
                                    No lossless.
                                    Support for bit depth 8-10.
                                  - high422:
                                    No lossless.
                                    Support for bit depth 8-10.
                                    Support for 4:2:0/4:2:2 chroma subsampling.
                                  - high444:
                                    Support for bit depth 8-10.
                                    Support for 4:2:0/4:2:2/4:4:4 chroma subsampling.
      --preset <string>       Use a preset to select encoding settings [medium]
                                  Overridden by user settings.
                                  - ultrafast:
                                    --no-8x8dct --aq-mode 0 --b-adapt 0
                                    --bframes 0 --no-cabac --no-deblock
                                    --no-mbtree --me dia --no-mixed-refs
                                    --partitions none --rc-lookahead 0 --ref 1
                                    --scenecut 0 --subme 0 --trellis 0
                                    --no-weightb --weightp 0
                                  - superfast:
                                    --no-mbtree --me dia --no-mixed-refs
                                    --partitions i8x8,i4x4 --rc-lookahead 0
                                    --ref 1 --subme 1 --trellis 0 --weightp 1
                                  - veryfast:
                                    --no-mixed-refs --rc-lookahead 10
                                    --ref 1 --subme 2 --trellis 0 --weightp 1
                                  - faster:
                                    --no-mixed-refs --rc-lookahead 20
                                    --ref 2 --subme 4 --weightp 1
                                  - fast:
                                    --rc-lookahead 30 --ref 2 --subme 6
                                    --weightp 1
                                  - medium:
                                    Default settings apply.
                                  - slow:
                                    --b-adapt 2 --direct auto --me umh
                                    --rc-lookahead 50 --ref 5 --subme 8
                                  - slower:
                                    --b-adapt 2 --direct auto --me umh
                                    --partitions all --rc-lookahead 60
                                    --ref 8 --subme 9 --trellis 2
                                  - veryslow:
                                    --b-adapt 2 --bframes 8 --direct auto
                                    --me umh --merange 24 --partitions all
                                    --ref 16 --subme 10 --trellis 2
                                    --rc-lookahead 60
                                  - placebo:
                                    --bframes 16 --b-adapt 2 --direct auto
                                    --slow-firstpass --no-fast-pskip
                                    --me tesa --merange 24 --partitions all
                                    --rc-lookahead 60 --ref 16 --subme 11
                                    --trellis 2
      --tune <string>         Tune the settings for a particular type of source
                              or situation
                                  Overridden by user settings.
                                  Multiple tunings are separated by commas.
                                  Only one psy tuning can be used at a time.
                                  - film (psy tuning):
                                    --deblock -1:-1 --psy-rd <unset>:0.15
                                  - animation (psy tuning):
                                    --bframes {+2} --deblock 1:1
                                    --psy-rd 0.4:<unset> --aq-strength 0.6
                                    --ref {Double if >1 else 1}
                                  - grain (psy tuning):
                                    --aq-strength 0.5 --no-dct-decimate
                                    --deadzone-inter 6 --deadzone-intra 6
                                    --deblock -2:-2 --ipratio 1.1 
                                    --pbratio 1.1 --psy-rd <unset>:0.25
                                    --qcomp 0.8
                                  - stillimage (psy tuning):
                                    --aq-strength 1.2 --deblock -3:-3
                                    --psy-rd 2.0:0.7
                                  - psnr (psy tuning):
                                    --aq-mode 0 --no-psy
                                  - ssim (psy tuning):
                                    --aq-mode 2 --no-psy
                                  - fastdecode:
                                    --no-cabac --no-deblock --no-weightb
                                    --weightp 0
                                  - zerolatency:
                                    --bframes 0 --force-cfr --no-mbtree
                                    --sync-lookahead 0 --sliced-threads
                                    --rc-lookahead 0
      --slow-firstpass        Do not force these faster settings with --pass 1:
                                  --no-8x8dct --me dia --partitions none
                                  --ref 1 --subme {2 if >2 else unchanged}
                                  --trellis 0 --fast-pskip

Frame-type options:

  -I, --keyint <integer or "infinite"> Maximum GOP size [250]
  -i, --min-keyint <integer>  Minimum GOP size [auto]
      --no-scenecut           Disable adaptive I-frame decision
      --scenecut <integer>    How aggressively to insert extra I-frames [40]
      --intra-refresh         Use Periodic Intra Refresh instead of IDR frames
  -b, --bframes <integer>     Number of B-frames between I and P [3]
      --b-adapt <integer>     Adaptive B-frame decision method [1]
                                  Higher values may lower threading efficiency.
                                  - 0: Disabled
                                  - 1: Fast
                                  - 2: Optimal (slow with high --bframes)
      --b-bias <integer>      Influences how often B-frames are used [0]
      --b-pyramid <string>    Keep some B-frames as references [normal]
                                  - none: Disabled
                                  - strict: Strictly hierarchical pyramid
                                  - normal: Non-strict (not Blu-ray compatible)
      --open-gop              Use recovery points to close GOPs
                              Only available with b-frames
      --no-cabac              Disable CABAC
  -r, --ref <integer>         Number of reference frames [3]
      --no-deblock            Disable loop filter
  -f, --deblock <alpha:beta>  Loop filter parameters [0:0]
      --slices <integer>      Number of slices per frame; forces rectangular
                              slices and is overridden by other slicing options
      --slices-max <integer>  Absolute maximum slices per frame; overrides
                              slice-max-size/slice-max-mbs when necessary
      --slice-max-size <integer> Limit the size of each slice in bytes
      --slice-max-mbs <integer> Limit the size of each slice in macroblocks (max)
      --slice-min-mbs <integer> Limit the size of each slice in macroblocks (min)
      --tff                   Enable interlaced mode (top field first)
      --bff                   Enable interlaced mode (bottom field first)
      --constrained-intra     Enable constrained intra prediction.
      --pulldown <string>     Use soft pulldown to change frame rate
                                  - none, 22, 32, 64, double, triple, euro (requires cfr input)
      --fake-interlaced       Flag stream as interlaced but encode progressive.
                              Makes it possible to encode 25p and 30p Blu-Ray
                              streams. Ignored in interlaced mode.
      --frame-packing <integer> For stereoscopic videos define frame arrangement
                                  - 0: checkerboard - pixels are alternatively from L and R
                                  - 1: column alternation - L and R are interlaced by column
                                  - 2: row alternation - L and R are interlaced by row
                                  - 3: side by side - L is on the left, R on the right
                                  - 4: top bottom - L is on top, R on bottom
                                  - 5: frame alternation - one view per frame
                                  - 6: mono - 2D frame without any frame packing
                                  - 7: tile format - L is on top-left, R split across

Ratecontrol:

  -q, --qp <integer>          Force constant QP (0-69, 0=lossless)
  -B, --bitrate <integer>     Set bitrate (kbit/s)
      --crf <float>           Quality-based VBR (0-51) [23.0]
      --rc-lookahead <integer> Number of frames for frametype lookahead [40]
      --vbv-maxrate <integer> Max local bitrate (kbit/s) [0]
      --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [0]
      --vbv-init <float>      Initial VBV buffer occupancy [0.9]
      --crf-max <float>       With CRF+VBV, limit RF to this value
                                  May cause VBV underflows!
      --qpmin <integer>       Set min QP [0]
      --qpmax <integer>       Set max QP [69]
      --qpstep <integer>      Set max QP step [4]
      --ratetol <float>       Tolerance of ABR ratecontrol and VBV [1.0]
      --ipratio <float>       QP factor between I and P [1.40]
      --pbratio <float>       QP factor between P and B [1.30]
      --chroma-qp-offset <integer>  QP difference between chroma and luma [0]
      --aq-mode <integer>     AQ method [1]
                                  - 0: Disabled
                                  - 1: Variance AQ (complexity mask)
                                  - 2: Auto-variance AQ
                                  - 3: Auto-variance AQ with bias to dark scenes
      --aq-strength <float>   Reduces blocking and blurring in flat and
                              textured areas. [1.0]

  -p, --pass <integer>        Enable multipass ratecontrol
                                  - 1: First pass, creates stats file
                                  - 2: Last pass, does not overwrite stats file
                                  - 3: Nth pass, overwrites stats file
      --stats <string>        Filename for 2 pass stats ["x264_2pass.log"]
      --no-mbtree             Disable mb-tree ratecontrol.
      --qcomp <float>         QP curve compression [0.60]
      --cplxblur <float>      Reduce fluctuations in QP (before curve compression) [20.0]
      --qblur <float>         Reduce fluctuations in QP (after curve compression) [0.5]
      --zones <zone0>/<zone1>/...  Tweak the bitrate of regions of the video
                              Each zone is of the form
                                  <start frame>,<end frame>,<option>
                                  where <option> is either
                                      q=<integer> (force QP)
                                  or  b=<float> (bitrate multiplier)
      --qpfile <string>       Force frametypes and QPs for some or all frames
                              Format of each line: framenumber frametype QP
                              QP is optional (none lets x264 choose). Frametypes: I,i,K,P,B,b.
                                  K=<I or i> depending on open-gop setting
                              QPs are restricted by qpmin/qpmax.

Analysis:

  -A, --partitions <string>   Partitions to consider ["p8x8,b8x8,i8x8,i4x4"]
                                  - p8x8, p4x4, b8x8, i8x8, i4x4
                                  - none, all
                                  (p4x4 requires p8x8\. i8x8 requires --8x8dct.)
      --direct <string>       Direct MV prediction mode ["spatial"]
                                  - none, spatial, temporal, auto
      --no-weightb            Disable weighted prediction for B-frames
      --weightp <integer>     Weighted prediction for P-frames [2]
                                  - 0: Disabled
                                  - 1: Weighted refs
                                  - 2: Weighted refs + Duplicates
      --me <string>           Integer pixel motion estimation method ["hex"]
                                  - dia: diamond search, radius 1 (fast)
                                  - hex: hexagonal search, radius 2
                                  - umh: uneven multi-hexagon search
                                  - esa: exhaustive search
                                  - tesa: hadamard exhaustive search (slow)
      --merange <integer>     Maximum motion vector search range [16]
      --mvrange <integer>     Maximum motion vector length [-1 (auto)]
      --mvrange-thread <int>  Minimum buffer between threads [-1 (auto)]
  -m, --subme <integer>       Subpixel motion estimation and mode decision [7]
                                  - 0: fullpel only (not recommended)
                                  - 1: SAD mode decision, one qpel iteration
                                  - 2: SATD mode decision
                                  - 3-5: Progressively more qpel
                                  - 6: RD mode decision for I/P-frames
                                  - 7: RD mode decision for all frames
                                  - 8: RD refinement for I/P-frames
                                  - 9: RD refinement for all frames
                                  - 10: QP-RD - requires trellis=2, aq-mode>0
                                  - 11: Full RD: disable all early terminations
      --psy-rd <float:float>  Strength of psychovisual optimization ["1.0:0.0"]
                                  #1: RD (requires subme>=6)
                                  #2: Trellis (requires trellis, experimental)
      --no-psy                Disable all visual optimizations that worsen
                              both PSNR and SSIM.
      --no-mixed-refs         Do not decide references on a per partition basis
      --no-chroma-me          Ignore chroma in motion estimation
      --no-8x8dct             Disable adaptive spatial transform size
  -t, --trellis <integer>     Trellis RD quantization. [1]
                                  - 0: disabled
                                  - 1: enabled only on the final encode of a MB
                                  - 2: enabled on all mode decisions
      --no-fast-pskip         Disables early SKIP detection on P-frames
      --no-dct-decimate       Disables coefficient thresholding on P-frames
      --nr <integer>          Noise reduction [0]

      --deadzone-inter <int>  Set the size of the inter luma quantization deadzone [21]
      --deadzone-intra <int>  Set the size of the intra luma quantization deadzone [11]
                                  Deadzones should be in the range 0 - 32.
      --cqm <string>          Preset quant matrices ["flat"]
                                  - jvt, flat
      --cqmfile <string>      Read custom quant matrices from a JM-compatible file
                                  Overrides any other --cqm* options.
      --cqm4 <list>           Set all 4x4 quant matrices
                                  Takes a comma-separated list of 16 integers.
      --cqm8 <list>           Set all 8x8 quant matrices
                                  Takes a comma-separated list of 64 integers.
      --cqm4i, --cqm4p, --cqm8i, --cqm8p <list>
                              Set both luma and chroma quant matrices
      --cqm4iy, --cqm4ic, --cqm4py, --cqm4pc <list>
                              Set individual quant matrices

Video Usability Info (Annex E):
The VUI settings are not used by the encoder but are merely suggestions to
the playback equipment. See doc/vui.txt for details. Use at your own risk.

      --overscan <string>     Specify crop overscan setting ["undef"]
                                  - undef, show, crop
      --videoformat <string>  Specify video format ["undef"]
                                  - component, pal, ntsc, secam, mac, undef
      --range <string>        Specify color range ["auto"]
                                  - auto, tv, pc
      --colorprim <string>    Specify color primaries ["undef"]
                                  - undef, bt709, bt470m, bt470bg, smpte170m,
                                    smpte240m, film, bt2020
      --transfer <string>     Specify transfer characteristics ["undef"]
                                  - undef, bt709, bt470m, bt470bg, smpte170m,
                                    smpte240m, linear, log100, log316,
                                    iec61966-2-4, bt1361e, iec61966-2-1,
                                    bt2020-10, bt2020-12
      --colormatrix <string>  Specify color matrix setting ["???"]
                                  - undef, bt709, fcc, bt470bg, smpte170m,
                                    smpte240m, GBR, YCgCo, bt2020nc, bt2020c
      --chromaloc <integer>   Specify chroma sample location (0 to 5) [0]
      --nal-hrd <string>      Signal HRD information (requires vbv-bufsize)
                                  - none, vbr, cbr (cbr not allowed in .mp4)
      --filler                Force hard-CBR and generate filler (implied by
                              --nal-hrd cbr)
      --pic-struct            Force pic_struct in Picture Timing SEI
      --crop-rect <string>    Add 'left,top,right,bottom' to the bitstream-level
                              cropping rectangle

Input/Output:

  -o, --output <string>       Specify output file
      --muxer <string>        Specify output container format ["auto"]
                                  - auto, raw, mkv, flv, mp4
      --demuxer <string>      Specify input container format ["auto"]
                                  - auto, raw, y4m, avs, lavf, ffms
      --input-fmt <string>    Specify input file format (requires lavf support)
      --input-csp <string>    Specify input colorspace format for raw input
                              - valid csps for `raw` demuxer:
                                i420, yv12, nv12, nv21, i422, yv16, nv16, i444, yv24, bgr, bgra, rgb
                              - valid csps for `lavf` demuxer:
                                yuv420p, yuyv422, rgb24, bgr24, yuv422p, 
                                yuv444p, yuv410p, yuv411p, gray, monow, monob, 
                                pal8, yuvj420p, yuvj422p, yuvj444p, xvmcmc, 
                                xvmcidct, uyvy422, uyyvyy411, bgr8, bgr4, 
                                bgr4_byte, rgb8, rgb4, rgb4_byte, nv12, nv21, 
                                argb, rgba, abgr, bgra, gray16be, gray16le, 
                                yuv440p, yuvj440p, yuva420p, vdpau_h264, 
                                vdpau_mpeg1, vdpau_mpeg2, vdpau_wmv3, 
                                vdpau_vc1, rgb48be, rgb48le, rgb565be, 
                                rgb565le, rgb555be, rgb555le, bgr565be, 
                                bgr565le, bgr555be, bgr555le, vaapi_moco, 
                                vaapi_idct, vaapi_vld, yuv420p16le, 
                                yuv420p16be, yuv422p16le, yuv422p16be, 
                                yuv444p16le, yuv444p16be, vdpau_mpeg4, 
                                dxva2_vld, rgb444le, rgb444be, bgr444le, 
                                bgr444be, ya8, bgr48be, bgr48le, yuv420p9be, 
                                yuv420p9le, yuv420p10be, yuv420p10le, 
                                yuv422p10be, yuv422p10le, yuv444p9be, 
                                yuv444p9le, yuv444p10be, yuv444p10le, 
                                yuv422p9be, yuv422p9le, vda_vld, gbrp, gbrp9be, 
                                gbrp9le, gbrp10be, gbrp10le, gbrp16be, 
                                gbrp16le, yuva420p9be, yuva420p9le, 
                                yuva422p9be, yuva422p9le, yuva444p9be, 
                                yuva444p9le, yuva420p10be, yuva420p10le, 
                                yuva422p10be, yuva422p10le, yuva444p10be, 
                                yuva444p10le, yuva420p16be, yuva420p16le, 
                                yuva422p16be, yuva422p16le, yuva444p16be, 
                                yuva444p16le, vdpau, xyz12le, xyz12be, nv16, 
                                nv20le, nv20be, yvyu422, vda, ya16be, ya16le, 
                                qsv, mmal, d3d11va_vld, rgba64be, rgba64le, 
                                bgra64be, bgra64le, 0rgb, rgb0, 0bgr, bgr0, 
                                yuva444p, yuva422p, yuv420p12be, yuv420p12le, 
                                yuv420p14be, yuv420p14le, yuv422p12be, 
                                yuv422p12le, yuv422p14be, yuv422p14le, 
                                yuv444p12be, yuv444p12le, yuv444p14be, 
                                yuv444p14le, gbrp12be, gbrp12le, gbrp14be, 
                                gbrp14le, gbrap, gbrap16be, gbrap16le, 
                                yuvj411p, bayer_bggr8, bayer_rggb8, 
                                bayer_gbrg8, bayer_grbg8, bayer_bggr16le, 
                                bayer_bggr16be, bayer_rggb16le, bayer_rggb16be, 
                                bayer_gbrg16le, bayer_gbrg16be, bayer_grbg16le, 
                                bayer_grbg16be, yuv440p10le, yuv440p10be, 
                                yuv440p12le, yuv440p12be, ayuv64le, ayuv64be, 
                                videotoolbox_vld
      --output-csp <string>   Specify output colorspace ["i420"]
                                  - i420, i422, i444, rgb
      --input-depth <integer> Specify input bit depth for raw input
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市腐巢,隨后出現(xiàn)的幾起案子品追,更是在濱河造成了極大的恐慌,老刑警劉巖冯丙,帶你破解...
    沈念sama閱讀 219,589評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件肉瓦,死亡現(xiàn)場離奇詭異,居然都是意外死亡胃惜,警方通過查閱死者的電腦和手機泞莉,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,615評論 3 396
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來船殉,“玉大人戒财,你說我怎么就攤上這事∞嘞遥” “怎么了?”我有些...
    開封第一講書人閱讀 165,933評論 0 356
  • 文/不壞的土叔 我叫張陵孝扛,是天一觀的道長列吼。 經(jīng)常有香客問我,道長苦始,這世上最難降的妖魔是什么寞钥? 我笑而不...
    開封第一講書人閱讀 58,976評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮陌选,結(jié)果婚禮上理郑,老公的妹妹穿的比我還像新娘蹄溉。我一直安慰自己,他們只是感情好您炉,可當(dāng)我...
    茶點故事閱讀 67,999評論 6 393
  • 文/花漫 我一把揭開白布柒爵。 她就那樣靜靜地躺著,像睡著了一般赚爵。 火紅的嫁衣襯著肌膚如雪棉胀。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,775評論 1 307
  • 那天冀膝,我揣著相機與錄音唁奢,去河邊找鬼。 笑死窝剖,一個胖子當(dāng)著我的面吹牛麻掸,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播赐纱,決...
    沈念sama閱讀 40,474評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼脊奋,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了千所?” 一聲冷哼從身側(cè)響起狂魔,我...
    開封第一講書人閱讀 39,359評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎淫痰,沒想到半個月后最楷,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,854評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡待错,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,007評論 3 338
  • 正文 我和宋清朗相戀三年籽孙,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片火俄。...
    茶點故事閱讀 40,146評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡犯建,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出瓜客,到底是詐尸還是另有隱情适瓦,我是刑警寧澤,帶...
    沈念sama閱讀 35,826評論 5 346
  • 正文 年R本政府宣布谱仪,位于F島的核電站玻熙,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏疯攒。R本人自食惡果不足惜嗦随,卻給世界環(huán)境...
    茶點故事閱讀 41,484評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望敬尺。 院中可真熱鬧枚尼,春花似錦贴浙、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,029評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至锭汛,卻和暖如春笨奠,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背唤殴。 一陣腳步聲響...
    開封第一講書人閱讀 33,153評論 1 272
  • 我被黑心中介騙來泰國打工般婆, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人朵逝。 一個月前我還...
    沈念sama閱讀 48,420評論 3 373
  • 正文 我出身青樓蔚袍,卻偏偏與公主長得像,于是被迫代替她去往敵國和親配名。 傳聞我的和親對象是個殘疾皇子啤咽,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,107評論 2 356

推薦閱讀更多精彩內(nèi)容