Search code examples
video-streamingh.264mpeg-4bytestream

How to find any of I/B/P frames in h264?


I need to find any (I/B/P) new frame in h264 byte stream.

I heard about NAL header, but I have such a strange stream:

00 00 00 01 09 F0 00 00 00 01 
67 64 00 1E AC B2 01 40 5F F2 
E0 22 00 00 07 D2 00 01 D4 C0 
1E 2C 5C 90 00 00 00 01 68 EB 
C3 CB 22 C0 00 00 01 06 05 FF 
  1. What's mean 0x09 0xF0 between 00 00 00 01 ?
  2. How to detect new frame (any of I/B/P) ?

Solution

  • Where to start.

    First off 0x09 0xF0 is an access unit delimiter. This is the start of your frame. But note, this is an optional NALU, and may not exist in all frames. Second, a frame can be made up of multiple slices, and each slice can be of type I/P/B. So it is possible to find a frame that contains all three slice types. I can go into more detail on how to determine the slice type, and and how to find the start of a frame if no AUD is present. But both topics are extremely large, and should (And probably do) have their own Stack Overflow questions.