How do I indentify an I-frame in H265 stream?

1.2k views Asked by At

I am working on a C++ application in which my application is receiving H265 frames from an external application and stores it on disk whenever required, but the storing needs to be start only from I-frame because if it starts from P frame, those frames would be meaningless. So how do I identify the I-frame from it?

I am new to video encoding and decoding and I am aware of following:

  • 00 00 00 01 is start of NAL unit
  • SPS starts with 67
  • PPS starts with 68
1

There are 1 answers

2
Markus Schumann On BEST ANSWER

Here are some of the NAL unit types for H.265:

  • IDR = 19 or 20
  • SPS = 33
  • PPS = 34

So your assumption about SPS, PPS values is incorrect.

NAL Unit structure:

"StartCode" "Byte" "Payload"

To get the NAL unit type you have to do (Byte >> 1) & 0x3f.

You need to look for an IDR frame (instant decoder refresh; type 19 or 20).