Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this H264 NAL Header Mean?

Tags:

0000 0109 1000 0001 6742 0020 e900 800c
3200 0001 68ce 3c80 0000 0001 6588 801a

As far as I know, 0000 01 is the start prefix code to identify a NAL Unit. What does "09 .... " mean? Is it the header type byte?

like image 760
ablmf Avatar asked Nov 06 '09 04:11

ablmf


People also ask

What is NAL unit in h264?

The Network Abstraction Layer (NAL) is a part of the H. 264/AVC and HEVC video coding standards. The main goal of the NAL is the provision of a "network-friendly" video representation addressing "conversational" (video telephony) and "non conversational" (storage, broadcast, or streaming) applications.

What is NAL data?

NAL offers data management policy and planning, repository management, data and metadata curation and consultation, and preservation. Current domain and related informatics expertise includes biological sciences, geospatial and biophysical sciences, genomics, federal open data policy, and life cycle assessment.

What is SPS and PPS in h264?

264 bitstream: the Sequence Parameter Set (SPS) and the Picture Parameter Set (PPS). Both entities contain information that an H. 264 decoder needs to decode the video data, for example, the resolution and frame rate of the video.

What is picture parameter set?

Picture Parameter Set (PPS): Similar to the SPS, this non-VCL NALU contains information on entropy coding mode, slice groups, motion prediction, quantization parameters (QP), and deblocking filters.


3 Answers

0x000001 is the NAL start prefix code (it can also be 0x00000001, depends on the encoder implementation). 0x09 is 0b00001001, which means F=0, NRI = 0, and type is 0b01001. That particular type is an access unit delimiter. Notice that it is immediately followed by another NAL unit defined by 0x67, which is a NAL type of 7, which is the sequence parameter set.

There's also the picture parameter set:

00 0001 68...

...and the start of a keyframe:

0000 0001 65...

like image 158
kidjan Avatar answered Sep 23 '22 09:09

kidjan


The key reference to figuring out what kind of NAL you are looking at is http://www.itu.int/rec/T-REC-H.264-201304-S . Specifically, the table on page 63 (as of Jan 2014) lists all valid NAL types.

To figure out what you are looking out look at the first 4 bytes. If the NAL is in "Annex B" framing they will either be 00 00 01 or 00 00 00 01. This sequence is forbidden/suppressed within the H.264 bitstream so if you see it you know for certain that you are looking at the start of a NAL. The NAL type is the 5 low order bits after the 1. In code:

int nalType = p[2] == 1 ? (p[3] & 0x1f) : (p[4] & 0x1f);

Also in H.264 jargon IDR means I-frame and non-IDR means P or B frames.

With the above information we can look at the above stream and see an access unit delimiter, followed by an SPS, PPS, and first I-Frame.

like image 45
Yaur Avatar answered Sep 22 '22 09:09

Yaur


    0000 0109 1000 0001 6742 0020 e900 800c
    3200 0001 68ce 3c80 0000 0001 6588 801a

-> 000001| 09 (AUD)| 10 | 000001 | 67(SPS) | xxxx (SPS data)
   xx | 000001 | 68 (PPS)| xxxx (PPS data)

AUD, SPS, PPS is type of NALU (Network Abstraction Layer Units) NALU have about 31 types.

09 AUD mean Access Unit Delimiter.

Access Unit Delimiter (AUD). An AUD is an optional NALU that can be use to delimit frames in an elementary stream. It is not required (unless otherwise stated by the container/protocol, like TS), and is often not included in order to save space, but it can be useful to finds the start of a frame without having to fully parse each NALU.

Check this answer for more information.

I also have a question about how to decode h264 stream (in iOS).

like image 9
Nhat Dinh Avatar answered Sep 22 '22 09:09

Nhat Dinh