An H264 file is a stream of NAL (Network Abstraction Layer) units, each encoding a frame (I, B, or P). What is the best way to parse this file and to extract sizes and detect ends of each NAL unit in the file, as well as detect the type of frame the NAL unit contains?
If you're not actually trying to decode the frames, you can write a simple 'parser' by reading the h.264 byte stream and looking for NAL unit signature.
Here's what you need to know:
So, if you find 3 bytes [00 00 01] in sequence, very likely it's the beginning of the NAL unit. Then you will need to parse the the next two bytes [X Y] to find out the type of frame. Please refer to the spec for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With