<p>The easiest way is to retime remaining frames using setpts.</p>
<p><code>ffmpeg -i in.mp4 -vf &quot;blackframe=amount=0:threshold=92, metadata=select:key='lavfi.blackframe.pblack':value=45:function=less,setpts=N/FR/TB&quot; -vsync 0  outz.mp4</code></p>

CC BY-SA 4.0
2021-04-07T11:26:25.890Z
2021-04-07T11:26:25.890Z
Gyan
<p>I am working off this answer <a href="https://video.stackexchange.com/questions/22159/how-to-extract-only-frames-from-videos-that-have-certain-levels-of-luminosity">here</a>. I have calibrated my video such that the following code perfectly exports the frames I want to keep</p>
<pre><code>ffmpeg -i in.mp4 -vf &quot;blackframe=amount=0:threshold=92, metadata=select:key='lavfi.blackframe.pblack':value=45:function=less&quot; -vsync 0  img%d.jpg
</code></pre>
<p>I modified the code slightly to export to a video</p>
<pre><code>ffmpeg -i in.mp4 -vf &quot;blackframe=amount=0:threshold=92, metadata=select:key='lavfi.blackframe.pblack':value=45:function=less&quot; -vsync 0  outz.mp4
</code></pre>
<p>The problem that I face is the output video is the same length as the input. The correct frames are being dropped but I am guessing the timestamp is not being adjusted because the video appears to pause (shows last non dropped frame) during a playback of removed frames.</p>
<p>I guess I could output the image files to another video editor and recompile into a video but I'd like to do this all within ffmpeg if possible.</p>
<p>Thanks!</p>

<video><ffmpeg><video-editor>
Removing frames from a video - how to make playback not pause during removed frames (i.e. assign new timestamps)
GDG
# Removing frames from a video - how to make playback not pause during removed frames (i.e. assign new timestamps)

(Asked by: username_0 on 2021-04-07)

I am working off this answer here. I have calibrated my video such that the following code perfectly exports the frames I want to keep
ffmpeg -i in.mp4 -vf "blackframe=amount=0:threshold=92, metadata=select:key='lavfi.blackframe.pblack':value=45:function=less" -vsync 0  img%d.jpg

I modified the code slightly to export to a video
ffmpeg -i in.mp4 -vf "blackframe=amount=0:threshold=92, metadata=select:key='lavfi.blackframe.pblack':value=45:function=less" -vsync 0  outz.mp4

The problem that I face is the output video is the same length as the input. The correct frames are being dropped but I am guessing the timestamp is not being adjusted because the video appears to pause (shows last non dropped frame) during a playback of removed frames.
I guess I could output the image files to another video editor and recompile into a video but I'd like to do this all within ffmpeg if possible.
Thanks!

**Tags:** video, ffmpeg, video-editor


---

## 1 answers

### Answer by username_1 on 2021-04-07. Score: 1

The easiest way is to retime remaining frames using setpts.

`ffmpeg -i in.mp4 -vf "blackframe=amount=0:threshold=92, metadata=select:key='lavfi.blackframe.pblack':value=45:function=less,setpts=N/FR/TB" -vsync 0 outz.mp4`


---

