====== Get h264 level based on number of RefFrames ====== Number of [[http://en.wikipedia.org/wiki/Reference_frame_(video) | reference frames]] is one of the most important indicators of [[http://en.wikipedia.org/wiki/H264 | H264]] (avc) level. Devices usually fail to play videos with level > 4.1 (on a High profile). Use this formula to work out dpbMbs value (more details see [[http://en.wikipedia.org/wiki/H264#Decoded_picture_buffering | Wikipedia]]): ''dpbMbs = (width * height * ref_frames) / 256'' Where MaxDpbMbs is a constant value provided in the table below as a function of level number, and width and height are the picture width and frame height for the coded video data, expressed in pixels. This formula is specified in sections A.3.1.h and A.3.2.f of the 2009 edition of the standard. ^ Level ^ 1 ^ 1b ^ 1.1 ^ 1.2 ^ 1.3 ^ 2 ^ 2.1 ^ 2.2 ^ 3 ^ 3.1 ^ 3.2 ^ 4 ^ 4.1 ^ 4.2 ^ 5 ^ 5.1 ^ |**MaxDpbMbs**|396|396|900|2,376|2,376|2,376|4,752|8,100|8,100|18,000|20,480|32,768|32,768|34,816|110,400|184,320| ====== Example ====== Below is MediaInfo output (stripped) of a video file. ''Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : High@L5.1 Format settings, CABAC : Yes Format settings, ReFrames : 12 frames Format settings, GOP : N=1 Codec ID : V_MPEG4/ISO/AVC Duration : 2h 23mn Bit rate : 10.7 Mbps Width : 1 920 pixels Height : 800 pixels'' Using the formula we get: ''dpbMbs = (1920* 800 * 12 ) / 256 = **72000**'' This value falls into level **5** (which is different to what is actually in the AVC header (5.1) - that is often the case). This file would be rejected by most players as it has both levels, the header value (5.1) and RefFrame based (5), higher than the widely used max. level of 4.1.