0

I'm trying to detect I-frames in TS by searching for the:

0x00 0x00 0x00 0x01 0x65

But, it doesn't work on some streams. In some streams this sequence occurs very rare. Is there any other way of detecting I-frames?

Edit: I also tried saving TS to a file and then extracting H.264 payload. The extracted payload contains only a few 0x00 0x00 0x00 0x01 0x65 byte sequences.

kytodrk
  • 163
  • 11

1 Answers1

1

What you are trying to do looks like a blind guess. H.264 specification is freely available. 00 00 00 01 is described in Annex B "Byte stream format" section. Then your 65 is what maps to section 7.3.1 "NAL unit syntax":

enter image description here

So you can split your byte stream into NAL units correctly and identify why your heuristic is not detecting I-Frames. Specifically, you are assuming two bit value to be equal to three exactly.

Also, slice types are defined as this:

enter image description here

See also:

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Okay, I should have looked for 0x25 and 0x45 as well. I tried, but these units are not present at all. Still, these standard fragments are not the answer to my question. – kytodrk Oct 05 '16 at 15:00
  • 1
    NAL type 5 will get you IDRs. To locate I frames which are not IDR, you will have to unwind bitstream for slice types - this is what table above references and linked answer explains as well. – Roman R. Oct 05 '16 at 15:05
  • You nailed it now. Non-IDR frames should have been processed as well!! – kytodrk Oct 05 '16 at 15:10