Answers.Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Use</p>
  
  <pre><code>ffmpeg -skip_frame nokey -i in.mp4 -vf showinfo -vsync 0 -f null -
  </code></pre>
  
  <p>The number of frames output is the IDR count.</p>
  
  <hr>
  
  <p>For the sample file, you can use the filter_units bitstream filter to keep only IDR frames</p>
  
  <pre><code>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
  </code></pre>
  
  <p>This will show the data of 118 frames, same as the analyzer.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-23T11:42:27.763Z
Answers.Text: Thanks for your response.                                                                   This issue is there for AVC content  as well.  Actually i need to grab pts values for each IDR frame
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-23T12:38:33.883Z
Answers.Text: I did a source check and AVC decoder appears to work the same way. Added filter in command to display PTS.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T14:00:14.487Z
Answers.Text: Hi it works fine only with interlaced output this issue is still there for progressive
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T15:09:55.957Z
Answers.Text: 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
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T16:08:22.793Z
Answers.Text: Let me test this. Can you share a HEVC stream along with Tektronix results for it.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-27T21:00:56.630Z
Answers.Text: I see only upload image option, Where can i upload stream, ??
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-28T05:49:14.837Z
Answers.Text: To some file-sharing service and post links
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-28T08:21:44.013Z
Answers.Text: 1. HEVC Progressive Stream : http://www.mediafire.com/file/4t2ujzf708ippca/HEVC-1080i25-STB_02_576i25.ts   
  2. HEVC Progressive textronic analyzer : http://www.mediafire.com/file/5ayuwtztwtwtig1/HEVC-1080p25-STB_02_576p25.txt
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-05T13:45:22.220Z
Answers.Text: @Mulya updated the stream and textronix analysis results, please have a look and let me know if you need any more information. It will be really great if i could get some help
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-17T07:25:57.360Z
Answers.Text: "The issue is ffmpeg iskey value is set to 1 for CRA frames as well. I need to collect only IDR frames "  Can anyone help me on this issue??
Answers.UserDisplayName: Ashok
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-17T07:37:17.610Z
Answers.Text: Sorry; forgot about this. Will look into it.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-20T18:00:35.877Z
Answers.Text: See new command.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-22T16:49:45.060Z
Answers.LastActivityDate: 2018-04-20T18:00:26.993Z
Answers.LastEditDate: 2018-04-20T18:00:26.993Z
Answers.UserDisplayName: Gyan
Body: <p><a href="https://i.sstatic.net/YQlvS.jpg" rel="noreferrer"><img src="https://i.sstatic.net/YQlvS.jpg" alt="enter image description here"></a>How does ffprobe identifies I frame as an IDR and sets <code>key_frame=1</code>.
  Is it for the scene change?</p>
  
  <p>My requirement is to filter out IDR frames: the steps I am following are</p>
  
  <ol>
  <li><code>ffprobe output_file -show_frames -select_streams v:0</code></li>
  <li>Filter above command results with <code>key_frame=1</code> values(as per ffprobe IDR)</li>
  <li>The total count i got is 259. Using ffprobe I am getting wrong sets of <code>key_frame=1</code> values.</li>
  <li>When i analyzed the same file with textronic analyzer I got correct values <code>idr = 118</code></li>
  </ol>
  
  <p>Textronix analyzer gives me below details for a a file verification.</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>Now how to identify correct IDR count using ffprobe?</p>
  
  <p>FFmpeg is setting iskey to 1 for CRA frames as well(tried with -skip_frame nokey). I need to collect only IDR frames </p>
  
Tags: <ffmpeg><hevc>
Title: How does ffprobe identifies I frame and IDR, when it sets key_frame=1
UserDisplayName: Ashok
ThreadText: # How does ffprobe identifies I frame and IDR, when it sets key_frame=1
  
  (Asked by: username_0 on 2018-03-22)
  
  [![enter image description here](https://i.sstatic.net/YQlvS.jpg)](https://i.sstatic.net/YQlvS.jpg)How 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
  
  **Tags:** ffmpeg, hevc
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-03-22. Score: 3
  
  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.
  
  > **Comments:**
  > **username_0**: Thanks for your response.                                                                   This issue is there for AVC content  as well.  Actually i need to grab pts values for each IDR frame  
  > **username_1**: I did a source check and AVC decoder appears to work the same way. Added filter in command to display PTS.  
  > **username_0**: Hi it works fine only with interlaced output this issue is still there for progressive  
  > **username_0**: 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  
  > **username_1**: Let me test this. Can you share a HEVC stream along with Tektronix results for it.  
  > **username_0**: I see only upload image option, Where can i upload stream, ??  
  > **username_1**: To some file-sharing service and post links  
  > **username_0**: 1. HEVC Progressive Stream : http://www.mediafire.com/file/4t2ujzf708ippca/HEVC-1080i25-STB_02_576i25.ts    2. HEVC Progressive textronic analyzer : http://www.mediafire.com/file/5ayuwtztwtwtig1/HEVC-1080p25-STB_02_576p25.txt  
  > **username_0**: @Mulya updated the stream and textronix analysis results, please have a look and let me know if you need any more information. It will be really great if i could get some help  
  > **username_0**: "The issue is ffmpeg iskey value is set to 1 for CRA frames as well. I need to collect only IDR frames "  Can anyone help me on this issue??  
  > **username_1**: Sorry; forgot about this. Will look into it.  
  > **username_1**: See new command.  
  
  ---
  
  