H.264 Profile、Level、Encoder三张简图 (fps = AVCodecContext->time_base.den / AVCodecContext->time_base.nu...

H.264 Profiles

Profiles are sets of capabilities. If your black box only supports the Baseline profile it'll not be able to decode a stream using High capabilities.

In VLC you can set the H.264 profile to be used by the x264 encoder like this:

--sout="#transcode{vcodec=h264,venc=x264{profile=baseline}...

H.264 Levels

Think of levels as a constraint/indicator of required decoder performance. If a decoder supports a certain level for a certain profile then it must be able to decode streams at that level and any of the lower levels.

First of all, the level for 640x480 @ 30 fps is 3 and not 2.2.

You can calculate this as following:

macrobolocks = ceil(640/16) * ceil(480/16) = 1200
macroblocks/s = macroblocks * 30 = 36000

The reason for ceil is that non-mod16 resolution are padded to a multiple of 16.

You then take a look at the H.264 Levels. You are within the frame size limit for 2.2 which is 1620 but the max decoding speed is greater than 20252 so you have to choose the next level wich is 3. You'll also have to consider the maximum bitrate for the Baseline profile in that table.

If you have an Android device you can download my H.264 Calculator app from the Amazon App Store (I can send you the apk if you don't like their Orwellian app permissions)

The x264 encoder will automatically choose a level based on your encoding parameters. With VLC you can actually set the flag yourself using something like:

--sout="#transcode{vcodec=h264,venc=x264{profile=baseline,level=22}"...

Beware, this sets the encoder output flag and doesn't actually produce a Level 2.2 stream. You can put any values you want, so it's possible to mark a Full HD stream at 60 fps as Level 2.2 even if it's nowhere the level limits.

VLC Transcoding

If you want to make sure you're sending a correct stream you'll need to transcode the source material. This is an example for 640x480 @ 30 fps which results in a Level 3 H.264 stream like I showed you above. If you want Level 2.2 you'll need to lower the resolution or framerate or both. Your video bitrate can go lower too in that case.

cvlc input.mp4 --sout="#transcode{vcodec=h264,venc=x264{profile=baseline},fps=30,width=640,height=480,vb=1372,acodec=mpga,ab=128,channels=2,samplerate=44100}:rtp{...}

Mediainfo

Mediainfo is a great tool to get information about a media file. You can check the specs of your input files, but it won't help you detect a wrong level which was forced into or wrongfully chosen by the encoder. The safest way is to re-encode.

 

下面的这个表拷贝自:  https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Levels

Levels

As the term is used in the standard, a "level" is a specified set of constraints that indicate a degree of required decoder performance for a profile. For example, a level of support within a profile specifies the maximum picture resolution, frame rate, and bit rate that a decoder may use. A decoder that conforms to a given level must be able to decode all bitstreams encoded for that level and all lower levels.

Levels with maximum property values
LevelMax decoding speedMax frame sizeMax video bit rate for video coding layer (VCL) kbit/sExamples for high resolution
@ highest frame rate
(max stored frames)
Toggle additional details
Luma samples/sMacroblocks/sLuma samplesMacroblocksBaseline, Extended
and Main Profiles
High ProfileHigh 10 Profile
1380,1601,48525,344996480192
128×96@30.9 (8)
176×144@15.0 (4)
1b380,1601,48525,34499128160384
128×96@30.9 (8)
176×144@15.0 (4)
1.1768,0003,000101,376396192240576
176×144@30.3 (9)
320×240@10.0 (3)
352×288@7.5 (2)
1.21,536,0006,000101,3763963844801,152
320×240@20.0 (7)
352×288@15.2 (6)
1.33,041,28011,880101,3763967689602,304
320×240@36.0 (7)
352×288@30.0 (6)
23,041,28011,880101,3763962,0002,5006,000
320×240@36.0 (7)
352×288@30.0 (6)
2.15,068,80019,800202,7527924,0005,00012,000
352×480@30.0 (7)
352×576@25.0 (6)
2.25,184,00020,250414,7201,6204,0005,00012,000
352×480@30.7 (12)
352×576@25.6 (10)
720×480@15.0 (6)
720×576@12.5 (5)
310,368,00040,500414,7201,62010,00012,50030,000
352×480@61.4 (12)
352×576@51.1 (10)
720×480@30.0 (6)
720×576@25.0 (5)
3.127,648,000108,000921,6003,60014,00017,50042,000
720×480@80.0 (13)
720×576@66.7 (11)
1,280×720@30.0 (5)
3.255,296,000216,0001,310,7205,12020,00025,00060,000
1,280×720@60.0 (5)
1,280×1,024@42.2 (4)
462,914,560245,7602,097,1528,19220,00025,00060,000
1,280×720@68.3 (9)
1,920×1,080@30.1 (4)
2,048×1,024@30.0 (4)
4.162,914,560245,7602,097,1528,19250,00062,500150,000
1,280×720@68.3 (9)
1,920×1,080@30.1 (4)
2,048×1,024@30.0 (4)
4.2133,693,440522,2402,228,2248,70450,00062,500150,000
1,280×720@145.1 (9)
1,920×1,080@64.0 (4)
2,048×1,080@60.0 (4)
5150,994,944589,8245,652,48022,080135,000168,750405,000
1,920×1,080@72.3 (13)
2,048×1,024@72.0 (13)
2,048×1,080@67.8 (12)
2,560×1,920@30.7 (5)
3,672×1,536@26.7 (5)
5.1251,658,240983,0409,437,18436,864240,000300,000720,000
1,920×1,080@120.5 (16)
2,560×1,920@51.2 (9)
3,840×2,160@31.7 (5)
4,096×2,048@30.0 (5)
4,096×2,160@28.5 (5)
4,096×2,304@26.7 (5)
5.2530,841,6002,073,6009,437,18436,864240,000300,000720,000
1,920×1,080@172.0 (16)
2,560×1,920@108.0 (9)
3,840×2,160@66.8 (5)
4,096×2,048@63.3 (5)
4,096×2,160@60.0 (5)
4,096×2,304@56.3 (5)

The maximum bit rate for High Profile is 1.25 times that of the Base/Extended/Main Profiles, 3 times for Hi10P, and 4 times for Hi422P/Hi444PP.

The number of luma samples is 16x16=256 times the number of macroblocks (and the number of luma samples per second is 256 times the number of macroblocks per second).

 

 

http://xcshen.blog.51cto.com/2835389/552669

 

H.264有四种画质级别,分别是BP、EP、MP、HP:

  1、BP-Baseline Profile:基本画质。支持I/P 帧,只支持无交错(Progressive)和CAVLC;
  2、EP-Extended profile:进阶画质。支持I/P/B/SP/SI 帧,只支持无交错(Progressive)和CAVLC;
  3、MP-Main profile:主流画质。提供I/P/B 帧,支持无交错(Progressive)和交错(Interlaced),
    也支持CAVLC 和CABAC 的支持;
  4、HP-High profile:高级画质。在main Profile 的基础上增加了8x8内部预测、自定义量化、 无损视频编码和更多的YUV 格式;

想 要说明H.264 HP与H.264 MP的区别就要讲到H.264的技术发展了。JVT于2003年完成H.264基本部分标准制定工作,包含Baseline profile、Extended profile和Main profile,分别包括不同的编码工具。之后JVT又完成了H.264 FRExt(即:Fidelity Range Extensions)扩展部分(Amendment)的制定工作,包括High profile(HP)、High 10 profile(Hi10P)、High 4:2:2 profile(Hi422P)、High 4:4:4 profile(Hi444P)4个profile。

   H.264 Baseline profile、Extended profile和Main profile都是针对8位样本数据、4:2:0格式的视频序列,FRExt将其扩展到8~12位样本数据,视频格式可以为4:2:0、4:2:2、 4:4:4,设立了High profile(HP)、High 10 profile(Hi10P)、High 4:2:2 profile(Hi422P)、High 4:4:4 profile(Hi444P) 4个profile,这4个profile都以Main profile为基础。

在 相同配置情况下,High profile(HP)可以比Main profile(MP)节省10%的码流量,比MPEG-2 MP节省60%的码流量,具有更好的编码性能。根据应用领域的不同,Baseline profile多应用于实时通信领域,Main profile多应用于流媒体领域,High profile则多应用于广电和存储领域。

H.264 Baseline Profile对应MPEG-4 SP
H.264 Main Profile对应MPEG-4 ASP
H.264 Extended Profile对应MPEG-4 ARTS or FGS
H.264 Baseline Profile对应MPEG-4 Studio。

 

H.264 Profile、Level、Encoder三张简图

【整理者】61ic.com
【提供者】QuestionMark         
【详细说明】H.264 Profile、Level、Encoder三张简图
取自 wikipedia                                                                                                                                                                                                                                     

h.264 profile



 

h.264 level

 
h.264 software encoder

本文出自 “流媒体技术工程组” 博客,请务必保留此出处http://xcshen.blog.51cto.com/2835389/552669

 

 

对于640*480,可以参考如下的level:

 

LevelVBV maximum bit rate [1000bits/s]VBV buffer size [1000bits]Macroblocks/sResolution and frame rate
1641751485128×96@30 or 176×144@15
1b1283501485128×96@30 or 176×144@15
1.11925003000176×144@30 or 320×240@10
1.238410006000176×144@60 or 320×240@20
1.3768200011880352×288@30
22000200011880352×288@30
2.14000400019800352×288@50
2.24000400020250352×288@50 or 640×480@15
3100001000040500720×480@30 or 720×576@25
3.114000140001080001280×720@30
3.220000200002160001280×720@60
420000250002457601920×1088@30 or 2Kx1K@30
4.150000625002457601920×1088@30 or 2Kx1K@30
4.250000625005222401920×1088@60 or or 2Kx1K@60
51350001350005898242560×1920@30
5.12400002400009830404Kx2K@30 or 4096×2304@25

 

从实践来看,640*480@15,级别可设置为(级别必须是2.2):

 

2.24000400020250352×288@50 or 640×480@15

Max macroblocks 可设置为 1620

从实践来看,640*480@30,级别可设置为(级别必须是3.0):

3.010000400036000640×480@30

Max macroblocks 可设置为1620

 

转载于:https://www.cnblogs.com/welhzh/p/4835864.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值