H.264/MPEG-4 AVC
lastmod 2025-04-16created 2015-02-0443 edits
H.264/MPEG-4 Part 10, or AVC (Advanced Video Coding), is a video compression standard and is currently one of the most common formats for recording, compressing, and distributing high-definition video. It boasts a very high data compression ratio.
This standard is the result of standardization carried out by the Joint Video Team (JVT), formed jointly by the ITU-T Video Coding Experts Group (VCEG) and the ISO/IEC Moving Picture Experts Group (MPEG). Therefore, ITU-T's H.264 and ISO/IEC's MPEG-4 Part 10 AVC (formally ISO/IEC 14496-10-MPEG-4 Part 10, Advanced Video Coding) are technically identical standards. The standard was published in May 2003.
H.264 is well known as one of the codec standards for Blu-ray Discs, because every Blu-ray Disc player must always be able to decode H.264. H.264 is also widely used in internet streaming services such as Vimeo, YouTube, and iTunes Store videos, in web software such as Adobe Flash Player and Microsoft Silverlight, and in various HDTV broadcasts (terrestrial: ATSC, ISDB-T, DVB-T, DVB-T2; cable: DVB-C; satellite: DVB-S, DVB-S2).
H.264 vs MPEG-4
When reading the datasheets of various processors in order to support video Encoding/Decoding on the Smart-I platform, the phrase "supports MPEG-4 and H.264" comes up often, but the naming of these two standards is actually ambiguous and causes a lot of confusion. Let's sort it out clearly. MPEG is a standard established by ISO (International Organization for Standardization), and H.264 is a standard established by ITU (International Telecommunication Union), so they were originally developed separately. MPEG4 came first, and MPEG4 consists of many parts. When it is written simply as MPEG4 without further notation, it means MPEG4 part2. Technically it is similar to ITU's H.263, with a lot of additional content. Later, ITU proposed H.264, an improvement on H.263, and ISO also adopted H.264 as a standard, where it went in as MPEG4 part10. That is why, for convenience, MPEG4 part2 is written as MPEG4 and MPEG4 part10 is called H.264.
Profiles and levels
A profile is a configuration that allows only specific techniques of a general-purpose video coding technology to be used, to suit an application area. The first published standard had three profiles: the Baseline profile, suited to low power and low resolution such as mobile broadcasting; the Main profile, made up of techniques that maximize the compression ratio; and the Extended profile, which adds techniques suited to streaming environments. Several more profiles were added as the standard was revised.
Profiles
The profiles currently provided in H.264/AVC are as follows.
| Profile number | Profile name | Key features | |
| 66 | Baseline | Low power, low resolution, low delay. Uses CAVLC only, no B-pictures | |
| 66 | Constrained Baseline | Uses only the techniques in the intersection of the Baseline and Main profiles | |
| 77 | Main | Improves efficiency with arithmetic coding and B-pictures | |
| 88 | Extended | Uses techniques for streaming and error resilience techniques | |
| FRExT | 100 | High | Uses 8x8 DCT, uses 8x8 intra prediction |
| 110 | High 10 | High profile + support for 10bit/pixel video | |
| 110 | High 10 Intra | Uses only the intra prediction techniques of the High10 profile | |
| 122 | High 4:2:2 | High10 profile + 4:2:2 color format support | |
| 122 | High 4:2:2 Intra | Uses only the intra prediction techniques of High 4:2:2 | |
| 244 | High 4:4:4 Predictive | Supports up to 14bit/pixel, 4:4:4 color format support | |
| 244 | High 4:4:4 Intra | Supports only the intra prediction techniques of High 4:4:4 Predictive | |
| 44 | CAVLC 4:4:4 Intra | High 4:4:4 Intra used with CAVLC (no CABAC) | |
Levels
| Level | Max | Max | Max video | Examples for high resolution Show/hide additional details |
| 1 | 1,485 | 99 | 64 | 128×[email protected] (8) 176×[email protected] (4) |
| 1b | 1,485 | 99 | 128 | 128×[email protected] (8) 176×[email protected] (4) |
| 1.1 | 3,000 | 396 | 192 | 176×[email protected] (9) 352×[email protected] (2) |
| 1.2 | 6,000 | 396 | 384 | 320×[email protected] (7) 352×[email protected] (6) |
| 1.3 | 11,880 | 396 | 768 | 320×[email protected] (7) 352×[email protected] (6) |
| 2 | 11,880 | 396 | 2,000 | 320×[email protected] (7) 352×[email protected] (6) |
| 2.1 | 19,800 | 792 | 4,000 | 352×[email protected] (7) 352×[email protected] (6) |
| 2.2 | 20,250 | 1,620 | 4,000 | 352×[email protected] (12) 720×[email protected] (5) |
| 3 | 40,500 | 1,620 | 10,000 | 352×[email protected] (12) 720×[email protected] (5) |
| 3.1 | 108,000 | 3,600 | 14,000 | 720×[email protected] (13) 1,280×[email protected] (5) |
| 3.2 | 216,000 | 5,120 | 20,000 | 1,280×[email protected] (5) 1,280×1,[email protected] (4) |
| 4 | 245,760 | 8,192 | 20,000 | 1,280×[email protected] (9) 2,048×1,[email protected] (4) |
| 4.1 | 245,760 | 8,192 | 50,000 | 1,280×[email protected] (9) 2,048×1,[email protected] (4) |
| 4.2 | 522,240 | 8,704 | 50,000 | 1,280×[email protected] (9) 2,048×1,[email protected] (4) |
| 5 | 589,824 | 22,080 | 135,000 | 1,920×1,[email protected] (13) 3,672×1,[email protected] (5) |
| 5.1 | 983,040 | 36,864 | 240,000 | 1,920×1,[email protected] (16) 4,096×2,[email protected] (5) |
| 5.2 | 2,073,600 | 36,864 | 240,000 | 1,920×1,[email protected] (16) 4,096×2,[email protected] (5) |
| 6 | 4,177,920 | 139,264 | 240,000 | 3,840×2,[email protected] (16) 8,192×4,[email protected] (5) |
| 6.1 | 8,355,840 | 139,264 | 480,000 | 3,840×2,[email protected] (16) 8,192×4,[email protected] (5) |
| 6.2 | 16,711,680 | 139,264 | 800,000 | 3,840×2,[email protected] (16) 8,192×4,[email protected] (5) |
Constant Rate Factor (CRF)
This bitrate control mode is good to use when you want to keep the best quality and care less about the file size. It is the recommended bitrate control method for most cases.
When the output file size is not important, this method lets the encoder adjust itself to keep a constant output quality across the entire file. This allows the most efficient compression possible in a single pass. It adjusts the quantizer value for each frame to get the bitrate it needs while keeping the requested quality level.
The drawback is that you cannot set a specific file size or bitrate. In other words, because you cannot limit the output so that it does not exceed a specific size, this method is not recommended for encoding video for streaming.
Choose a CRF value
The range of the CRF scale is 0–51, where
- "0" is lossless (for 8-bit; for 10-bit, use
-qp 0), - "23" is the default,
- and "51" is the worst quality.
A lower value generally means higher quality, and a subjectively sane range is 17–28.
- A CRF value of 17 or 18 is visually lossless or nearly so: it looks the same or nearly the same as the input video, but it is not technically fully lossless.
- Changes in the CRF value are exponential, so increasing the CRF value by 6 roughly halves the bitrate (file size), and decreasing it by 6 roughly doubles it.
- If the quality of the output video is satisfactory, try a higher CRF value; if the quality is poor, choose a lower value.
| Note |
| The 0–51 CRF quantizer scale mentioned on this page applies only to 8-bit x264. When compiled with 10-bit support, x264's quantizer scale is 0–63. (Internally, x264 itself uses a range of -12–51, but FFmpeg's libx264 wrapper converts it so that 0 is set to lossless. However, lossless is possible only in supported profiles, and the High 10 profile does not support lossless.) You can tell which bit depth is in use by checking the FFmpeg console output during encoding. For example, 8-bit shows yuv420p or a similar value, and 10-bit shows yuv420p10le or a similar value. In general, 8-bit is more common in distribution. |
Using network bandwidth effectively
- [Highly recommended] Using network camera bandwidth effectively: advanced 2 (CCTV, H264)
See CCTV.
Spec
- blog.naver.com/onlyou_4ever - H.264 Stream analysis 3
- H.264 Stream analysis
- FFMpeg x264 Header packet analysis
Storage capacity calculation
- Also see Dongkuk Dangjin Rolling Mill#Checking disk storage capacity.
H.264 Video Encoding Guide
- Encode/H.264 – FFmpeg - H.264 Video Encoding Guide
- FFMPEG - In-depth trial and error Ubuntu Korea Community Wiki
ITU-T Rec. H.264 & Annex B
Recommendation H.264 is a video codec standard defined by the International Telecommunication Union, Telecommunications Standardization Sector (ITU-T). It is available free of charge and can be downloaded from their website.
The standard defines a bytestream format, whose lowest level of abstraction is the NALU (Network Layer Abstraction Unit).
32 types of NALUs can exist, although about 11 are reserved or unused. Some carry video slice data, some don’t. Two NALU types will be important later in this discussion: SPS (Sequence Parameter Set) and PPS (Picture Parameter Set). Both are required to decode a video slice, and provide important information about the stream, such as its size and interpretation of the raw data.
H.264 leaves undefined how these NALUs are transported and framed. However, it does describe one possible scheme, in the Standard’s own Annex B. This scheme, for want of a better name, is generally referred to as Annex B.
The scheme consists in prefixing the NALUs with an easy-to-synchronize-to start code that cannot occur within a NALU: A 3- or 4-byte pattern 00 00 01 or 00 00 00 01. The rest of the NALU then follows. This scheme is popular in hardware and/or streaming situations because it allows acquiring bit-lock and byte-alignment easily, sends the SPS/PPS “in-band” periodically and thus allows one to tune into the stream at a random point to begin decoding, and has the interesting property that between NALUs one can validly send an arbitrary number of 0 bits or bytes.
FFmpeg Encoding
See FFmpeg:Tool#H.264.
License
Note that a "library license" and a "patent license" are different things.
See also
- MPEG (includes explanations of terms such as i-frame and GOP)
- Discrete Cosine Transform
- x264
- ts
- Broadway.js (JavaScript)
- Bitrate - includes how to calculate it and commonly used bitrates.
Favorite site
- Wikipedia (en) page on H.264/MPEG-4 AVC
- H.264 : Advanced video coding for generic audiovisual services
- ITU-T H.264 (V9) (02/2014) 4
Project
- H.264/AVC Software Coordination / Current software version: JM 19.0
- [Recommended] Structural analysis of the H.264/AVC encoder reference software 5 (JM)
Guide
- H.264: Discrete Cosine Transform (DCT) 6
- H.264: Quantization and Zig-zag scanning 7
- H.264: Basic concepts of video compression - RGB, YCbCr, subsampling 8
- H.264/AVC basics
- Overview of the H.264/AVC Video Coding Standard
- H.264/AVC video compression standard: the overall structure of H.264/AVC and the provisions on "profiles and levels"
- The h.264 Sequence Parameter Set
- [Recommended] x264 options summary :: Eureka Blog 9
Analysis
- H.264 - NAL Unit
- H.264 Stream analysis
- INFO - SoC - H.264 Stream analysis
- Understanding H.264 streams (NALU, SPS, PPS, ...)
Spec
- Dino's knowledge store :: H.264/AVC standard profiles and levels
- x264 options summary for MeGUI version 2460 10
References
-
https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=13189 ↩
-
Network_Camera_Bandwidth_Effective_Use_Advanced_Guide.pdf ↩
-
Blog.naver.com_-onlyou_4ever-_H.264_stream_analysis.pdf ↩
-
T-REC-H.264-201402-I.pdf ↩
-
JM_Analysis_Korean.pdf (well organized in Korean) ↩
-
H264-Discrete_Cosine_Transform.pdf ↩
-
H264-Quantization_Zig-zag-scanning.pdf ↩
-
H264-RGB_YCbCr_Subsampling.pdf ↩
-
Dongho.tistory.com_-_x264_options.pdf ↩
-
Ligel.tistory.com_-_MeGUI_2460_x264_Options.pdf ↩