2

enter image description hereHow does ffprobe identifies I frame as an IDR and sets key_frame=1. Is it for the scene change?

My requirement is to filter out IDR frames: the steps I am following are

  1. ffprobe output_file -show_frames -select_streams v:0
  2. Filter above command results with key_frame=1 values(as per ffprobe IDR)
  3. The total count i got is 259. Using ffprobe I am getting wrong sets of key_frame=1 values.
  4. When i analyzed the same file with textronic analyzer I got correct values idr = 118

Textronix analyzer gives me below details for a a file verification.

TotalPictures:Count[ 5864]
I Pictures: Count[  259]
P Pictures: Count[ 1059]
B Pictures: Count[ 4546]

RAP Pictures:Count[259]
IDR Pictures:Count[118] 
BLA Pictures:Count[0] 
CRA Pictures:Count[141]

Frames:     Count[ 5864]    Percentage[100.00]
Fields:     Count[    0]    Percentage[0.00]

GOP (in Pictures, between I): Count[258] AverageSize[22] MinSize[1] MaxSize[50]
CVS (in Pictures, between IDR):Count[117] AverageSize[50]MinSize[50]MaxSize[50]

Now how to identify correct IDR count using ffprobe?

FFmpeg is setting iskey to 1 for CRA frames as well(tried with -skip_frame nokey). I need to collect only IDR frames

2

It sounds like you're analyzing a HEVC bitstream. HEVC has multiple types of Random Access Pictures, only one of which clears the buffer. But ffmpeg flags all of them as keyframes.

You have to use the HEVC decoder to parse this info out. The skip_frame option, as implemented in the HEVC decoder, only decodes IDR frames.

Use

ffmpeg -skip_frame nokey -i in.mp4 -vf showinfo -vsync 0 -f null -

The number of frames output is the IDR count.


For the sample file, you can use the filter_units bitstream filter to keep only IDR frames

ffmpeg -copyts -i HEVC-1080i25-STB_02_576i25.ts -an -c copy -bsf:v filter_units="19-20" -f mpegts - | ffmpeg -copyts -i - -vf showinfo -f null NUL

This will show the data of 118 frames, same as the analyzer.

  • Thanks for your response. This issue is there for AVC content as well. Actually i need to grab pts values for each IDR frame – Ashok Mar 23 '18 at 11:42
  • I did a source check and AVC decoder appears to work the same way. Added filter in command to display PTS. – Gyan Mar 23 '18 at 12:38
  • Hi it works fine only with interlaced output this issue is still there for progressive – Ashok Mar 27 '18 at 14:00
  • The issue is ffmpeg iskey value is set to 1 for CRA frames as well. (Instantaneous Decoder Refresh (IDR), Clean Random Access (CRA), I need to collect only IDR frames – Ashok Mar 27 '18 at 15:09
  • Let me test this. Can you share a HEVC stream along with Tektronix results for it. – Gyan Mar 27 '18 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.