video-encodinghevcvideo-codecsh.265

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


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:


Solution

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

    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).