Body: <p>I'm trying to follow this tutorial: <a href="https://www.reddit.com/r/brokenanimegifs/wiki/tutorial" rel="nofollow noreferrer">https://www.reddit.com/r/brokenanimegifs/wiki/tutorial</a></p>
  
  <p>Everything works perfectly. On the basis of this tutorial, I even created my own little tool. It just removes original I-frames and replaces with new one, all works fine with h264 (libx264).</p>
  
  <p>Now I want to repeat this on the basis of x265, as it has a better algorithm for detecting motion and smearing the picture. But unfortunately, nothing works! I tried about such coding options:</p>
  
  <pre><code> ffmpeg -i source.avi -vcodec libx265 -an -bf 0 -x265-params no-pme:subme=1:\
   no-weightp:no-constrained-intra:no-temporal-layers:no-temporal-mvp:no-open-gop:\
   crf=15:bframes=0:radl=0:ctu-info=0:rc-lookahead=0:gop-lookahead=0:\
   lookahead-slices=0:lookahead-threads=0:b-adapt=0:bframe-bias=0:no-b-pyramid:\
   force-flush=1:frame-threads=1 -t 30 -y result.avi
  </code></pre>
  
  <p>But it did not help.</p>
  
  <p>I learned that x265 has many types of I-frames, I suspect that it's all about this. I can replace only the first I-frame in file, it works as before. But I can not change any other I-Frames and get the error in place of replacement, errors like:</p>
  
  <pre><code>  [hevc @ 0xb372940] Could not find ref with POC -60:00:09.17 bitrate=62974.5kbits/s dup=2 drop=0 speed=9.14x    
    [hevc @ 0xb372940] Could not find ref with POC -12:00:20.56 bitrate=62974.5kbits/s dup=2 drop=0 speed=10.2x 
  </code></pre>
  
  <p>Do you think you can repeat this with x265? Here exists any options to force IDR-frames and disable advanced coding techniques?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-21T05:21:14.000Z
Comments.Text: Use the last command in this [answer](https://video.stackexchange.com/a/23632/1871) to identify HEVC IDR frames and try to alter only those.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-21T06:53:06.877Z
Comments.Text: Thanks! I seen this post before, but I have opposite task: find I frames in stream (done at container level), RE-ENCODE this frames, inject in original streams, subsequent frames refer to the coded keyframe and for some reason an error occurs. I understand that the encoded frame, which I substitute, clears the buffer, but it should not be. So I'm looking for a way how to encode each frame sequence (GOP) most independently.
Comments.UserDisplayName: bukkojot
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-21T13:40:40.637Z
Comments.Text: Yeah, my answer will help you "*find I frames in stream*"  - only the IDR kind. For the remaining  Don't know of a direct option to suppress x265 from generating CRA/BLA frames. It could be a side-effect of some other options.
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-22T04:40:43.463Z
Comments.Text: Actually I parsing AVI container at byte level. I want to change ANY I-frame, as start every new scene in file. It will be perfect to force IDR-frames at new scenes.
Comments.UserDisplayName: bukkojot
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-22T04:45:36.410Z
Comments.Text: I think, I-frames in x265 is dependent frames. According to this: http://dustsigns.de/CMS/wp-content/uploads/HEVC.pdf - page 18, I need CRA / BLA / IDR only for frame replacing.
Comments.UserDisplayName: bukkojot
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-02T07:39:01.623Z
Comments.Text: After seeing some of the examples it wasn't clear why it would be a good idea to do this, usually the result is a mess; then I saw this example: https://i.imgur.com/3Yrajz0.gif where it really worked out great. I think you need to follow the tutorial **exactly**, using a different compressor is unlikely to duplicate the results. I found this Patch to suppress that error message: http://ffmpeg-devel.ffmpeg.narkive.com/7pHRUyTF/patch-avcodec-hevc-refs-silence-could-not-find-ref-with-poc-for-cra-bla - Changing too much is likely to affect whether or not it will even work. Good luck. 
Comments.UserDisplayName: Rob
Tags: <video><ffmpeg><encoding><h.264><h265>
Title: Replacing I-frames in h265 stream
UserDisplayName: bukkojot
ThreadText: # Replacing I-frames in h265 stream
  
  (Asked by: username_0 on 2018-04-21)
  
  I'm trying to follow this tutorial: <https://www.reddit.com/r/brokenanimegifs/wiki/tutorial>
  
  Everything works perfectly. On the basis of this tutorial, I even created my own little tool. It just removes original I-frames and replaces with new one, all works fine with h264 (libx264).
  
  Now I want to repeat this on the basis of x265, as it has a better algorithm for detecting motion and smearing the picture. But unfortunately, nothing works! I tried about such coding options:
  
  ```
   ffmpeg -i source.avi -vcodec libx265 -an -bf 0 -x265-params no-pme:subme=1:\
   no-weightp:no-constrained-intra:no-temporal-layers:no-temporal-mvp:no-open-gop:\
   crf=15:bframes=0:radl=0:ctu-info=0:rc-lookahead=0:gop-lookahead=0:\
   lookahead-slices=0:lookahead-threads=0:b-adapt=0:bframe-bias=0:no-b-pyramid:\
   force-flush=1:frame-threads=1 -t 30 -y result.avi
  
  ```
  
  But it did not help.
  
  I learned that x265 has many types of I-frames, I suspect that it's all about this. I can replace only the first I-frame in file, it works as before. But I can not change any other I-Frames and get the error in place of replacement, errors like:
  
  ```
    [hevc @ 0xb372940] Could not find ref with POC -60:00:09.17 bitrate=62974.5kbits/s dup=2 drop=0 speed=9.14x    
    [hevc @ 0xb372940] Could not find ref with POC -12:00:20.56 bitrate=62974.5kbits/s dup=2 drop=0 speed=10.2x 
  
  ```
  
  Do you think you can repeat this with x265? Here exists any options to force IDR-frames and disable advanced coding techniques?
  
  **Tags:** video, ffmpeg, encoding, h.264, h265
  
  > **Comments:**
  > **username_1**: Use the last command in this [answer](https://video.stackexchange.com/a/23632/1871) to identify HEVC IDR frames and try to alter only those.  
  > **username_0**: Thanks! I seen this post before, but I have opposite task: find I frames in stream (done at container level), RE-ENCODE this frames, inject in original streams, subsequent frames refer to the coded keyframe and for some reason an error occurs. I understand that the encoded frame, which I substitute, clears the buffer, but it should not be. So I'm looking for a way how to encode each frame sequence (GOP) most independently.  
  > **username_1**: Yeah, my answer will help you "*find I frames in stream*"  - only the IDR kind. For the remaining  Don't know of a direct option to suppress x265 from generating CRA/BLA frames. It could be a side-effect of some other options.  
  > **username_0**: Actually I parsing AVI container at byte level. I want to change ANY I-frame, as start every new scene in file. It will be perfect to force IDR-frames at new scenes.  
  > **username_0**: I think, I-frames in x265 is dependent frames. According to this: http://dustsigns.de/CMS/wp-content/uploads/HEVC.pdf - page 18, I need CRA / BLA / IDR only for frame replacing.  
  > **username_2**: After seeing some of the examples it wasn't clear why it would be a good idea to do this, usually the result is a mess; then I saw this example: https://i.imgur.com/3Yrajz0.gif where it really worked out great. I think you need to follow the tutorial **exactly**, using a different compressor is unlikely to duplicate the results. I found this Patch to suppress that error message: http://ffmpeg-devel.ffmpeg.narkive.com/7pHRUyTF/patch-avcodec-hevc-refs-silence-could-not-find-ref-with-poc-for-cra-bla - Changing too much is likely to affect whether or not it will even work. Good luck.   
  
  ---
  
  ## 0 answers
  
  