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.


1 Answer 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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