Answers.Body: <p>After poring over the documentation all weekend, I figured out how to use the minterpolate filter to do motion interpolation.  The full command is</p>
  
  <pre><code>ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less,minterpolate=mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1:me=fss -c:a copy out.mp4
  </code></pre>
  
  <p>These were the settings that gave me the best-looking results.  If these are too slow for you, you can try something like</p>
  
  <pre><code>ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less,minterpolate=mi_mode=mci:mc_mode=obmc:me_mode=bilat:vsbmc=0:me=tdls -c:a copy out.mp4
  </code></pre>
  
  <p>which went about 3x as fast in my testing.  You can find the documentation on the different minterpolate options <a href="https://ffmpeg.org/ffmpeg-filters.html#minterpolate" rel="nofollow noreferrer">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-08T03:50:53.860Z
Answers.LastActivityDate: 2019-09-08T03:50:53.860Z
Answers.UserDisplayName: BlueRaja - Danny Pflughoeft
Answers.Body: <p>After removing the black frames, you can insert the framerate filter to fill the gaps with blended frames.</p>
  
  <pre><code>ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less,framerate=fps=60000/1001 -c:a copy out.mp4
  </code></pre>
  
  <p>See docs for framerate filter. The filter will produce a CFR stream so vsync is not required.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-06T19:18:53.073Z
Answers.Text: This appears to fade out the previous frame and fade in the next one _(either that or the motion interpolation algorithm is extremely poor)_.  While it's definitely better than just holding a still frame, the results are still not great.  I'll accept this if no one finds anything better...
Answers.UserDisplayName: BlueRaja - Danny Pflughoeft
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-06T21:08:11.817Z
Answers.Text: The filter performs blending, so no motion interpolation. You can try the [minterpolate](http://ffmpeg.org/ffmpeg-filters.html#minterpolate) filter instead of framerate but it will be slow.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-08T22:47:28.720Z
Answers.Text: Thanks for pointing me to minterpolate! It works better than the 'framerate' filter, except in areas with fast movement or lots of consecutive missing frames.
Answers.UserDisplayName: BlueRaja - Danny Pflughoeft
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-05T11:40:14.313Z
Answers.LastActivityDate: 2019-09-05T11:40:14.313Z
Answers.UserDisplayName: Gyan
Answers.Body: <p>Not sure about FFMPEG, but it wouldn't hurt to try the free version of DaVinci Resolve.  From page 1351 of the user manual (yes, quite TLDR):</p>
  <blockquote>
  <p><strong>RepairFrame, Tween</strong></p>
  <p>The Tween and Repair Frame nodes are different from
  standard optical flow nodes because they have the OpticalFlow analysis
  and motion vector generation built in. Tween will compare two frames
  and create an in-between frame, which is good for recreating a missing
  or flawed frame. Repair Frame will look at frames on either side of
  the current frame and repair scratches, dust marks, and so on. Because
  these nodes work with flow values between non-sequential frames, they
  cannot use the optical flow stored in the input image’s
  Vector/BackVector channels, but rather must regenerate the flow of
  each frame, do their processing, and then destroy the flow channels.
  This being the case, these nodes are computationally expensive. For
  more information on Tween or Repair Frame see the Nodes Reference
  guide.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-06T19:15:13.027Z
Answers.Text: It seems "RepairFrame" has been renamed to "Remove dust and scratches" in the latest version?  I tried it but it didn't work at all.
Answers.UserDisplayName: BlueRaja - Danny Pflughoeft
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-08T02:22:45.847Z
Answers.Text: Works fine for me.  It's not called dust and scratches.  It's in the fusion tab.  Type shift+spacebar with the node editor active, and start typing "repairframe" or check under the "optical flow" subcategory of "tools" in the Effects Library.  If you don't see it there, it's a paid version only feature, in which case, I apologize for sending you on a wild goose chase.  It's hard to remember which things are and which aren't.  There isn't much that you can't do with  the free version, but every once in a while, you run into something.
Answers.UserDisplayName: Jason Conrad
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-04T23:56:30.107Z
Answers.LastActivityDate: 2019-09-04T23:56:30.107Z
Answers.LastEditDate: 2020-06-17T09:53:03.607Z
Answers.UserDisplayName: Jason Conrad
Body: <p>Due to a bug with Nvidia Shadowplay, I have a bunch of videos that <a href="https://gfycat.com/uglymerryarctichare" rel="nofollow noreferrer">look like this</a>.  A bunch of random frames have been replaced with pure black frames.</p>
  
  <p>I'd like to fix one of these videos to remove the flickering.  I saw an answer <a href="https://video.stackexchange.com/questions/23589/replace-black-frames-with-previous-frames">here</a> which suggests the following ffmpeg command:</p>
  
  <pre><code>ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less -vsync cfr -c:a copy out.mp4
  </code></pre>
  
  <p>However, this replaces all the black frames with the most recent non-black frame, which makes the video look like a slideshow.</p>
  
  <p>Is there any way to use a similar ffmpeg command (or any other tool) to use motion interpolation to fix the missing frames?</p>
  
Tags: <ffmpeg><video-editor><software-recommendation><filter>
Title: Replace all completely black frames with interpolated frames
UserDisplayName: BlueRaja - Danny Pflughoeft
ThreadText: # Replace all completely black frames with interpolated frames
  
  (Asked by: username_0 on 2019-09-02)
  
  Due to a bug with Nvidia Shadowplay, I have a bunch of videos that [look like this](https://gfycat.com/uglymerryarctichare). A bunch of random frames have been replaced with pure black frames.
  
  I'd like to fix one of these videos to remove the flickering. I saw an answer [here](https://video.stackexchange.com/questions/23589/replace-black-frames-with-previous-frames) which suggests the following ffmpeg command:
  
  ```
  ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less -vsync cfr -c:a copy out.mp4
  
  ```
  
  However, this replaces all the black frames with the most recent non-black frame, which makes the video look like a slideshow.
  
  Is there any way to use a similar ffmpeg command (or any other tool) to use motion interpolation to fix the missing frames?
  
  **Tags:** ffmpeg, video-editor, software-recommendation, filter
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2019-09-08. Score: 2 | Accepted answer
  
  After poring over the documentation all weekend, I figured out how to use the minterpolate filter to do motion interpolation. The full command is
  
  ```
  ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less,minterpolate=mi_mode=mci:mc_mode=aobmc:me_mode=bidir:vsbmc=1:me=fss -c:a copy out.mp4
  
  ```
  
  These were the settings that gave me the best-looking results. If these are too slow for you, you can try something like
  
  ```
  ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less,minterpolate=mi_mode=mci:mc_mode=obmc:me_mode=bilat:vsbmc=0:me=tdls -c:a copy out.mp4
  
  ```
  
  which went about 3x as fast in my testing. You can find the documentation on the different minterpolate options [here](https://ffmpeg.org/ffmpeg-filters.html#minterpolate).
  
  
  ---
  
  ### Answer by username_1 on 2019-09-05. Score: 1
  
  After removing the black frames, you can insert the framerate filter to fill the gaps with blended frames.
  
  ```
  ffmpeg -i in.mp4 -vf blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=50:function=less,framerate=fps=60000/1001 -c:a copy out.mp4
  
  ```
  
  See docs for framerate filter. The filter will produce a CFR stream so vsync is not required.
  
  > **Comments:**
  > **username_0**: This appears to fade out the previous frame and fade in the next one _(either that or the motion interpolation algorithm is extremely poor)_.  While it's definitely better than just holding a still frame, the results are still not great.  I'll accept this if no one finds anything better...  
  > **username_1**: The filter performs blending, so no motion interpolation. You can try the [minterpolate](http://ffmpeg.org/ffmpeg-filters.html#minterpolate) filter instead of framerate but it will be slow.  
  > **username_0**: Thanks for pointing me to minterpolate! It works better than the 'framerate' filter, except in areas with fast movement or lots of consecutive missing frames.  
  
  ---
  
  ### Answer by username_2 on 2019-09-04. Score: 0
  
  Not sure about FFMPEG, but it wouldn't hurt to try the free version of DaVinci Resolve. From page 1351 of the user manual (yes, quite TLDR):
  
  > **RepairFrame, Tween**
  >
  > The Tween and Repair Frame nodes are different from
  > standard optical flow nodes because they have the OpticalFlow analysis
  > and motion vector generation built in. Tween will compare two frames
  > and create an in-between frame, which is good for recreating a missing
  > or flawed frame. Repair Frame will look at frames on either side of
  > the current frame and repair scratches, dust marks, and so on. Because
  > these nodes work with flow values between non-sequential frames, they
  > cannot use the optical flow stored in the input image’s
  > Vector/BackVector channels, but rather must regenerate the flow of
  > each frame, do their processing, and then destroy the flow channels.
  > This being the case, these nodes are computationally expensive. For
  > more information on Tween or Repair Frame see the Nodes Reference
  > guide.
  
  > **Comments:**
  > **username_0**: It seems "RepairFrame" has been renamed to "Remove dust and scratches" in the latest version?  I tried it but it didn't work at all.  
  > **username_2**: Works fine for me.  It's not called dust and scratches.  It's in the fusion tab.  Type shift+spacebar with the node editor active, and start typing "repairframe" or check under the "optical flow" subcategory of "tools" in the Effects Library.  If you don't see it there, it's a paid version only feature, in which case, I apologize for sending you on a wild goose chase.  It's hard to remember which things are and which aren't.  There isn't much that you can't do with  the free version, but every once in a while, you run into something.  
  
  ---
  
  