0

When dealing with corrupted videos, ffmpeg is a great to tool to automatically fix errors.

Is there a way, with ffmpeg or another similar tool, to automatically remove/drop/trim/cut away frozen parts from a file, both video and audio streams?

Using a combination of mpdecimate and map it's possible to obtain the video stream only with:

ffmpeg -i input.ext -vf mpdecimate -map 0:v output.mp4

How to do the same thing with all streams of the file, audio and video?

Given a video with two streams like:

     0       1         2       3         4
video|AAAAAAA|FFFFFFFFF|BBBBBBB|FFFFFFFFF|
audio|XXXXXXX|YYYYYYYYY|ZZZZZZZ|KKKKKKKKK|

where A and B are the good parts to mantain and F are the frozen parts to be trimmed away, I want obtain a "cleaned" video (with the frozen parts and its associated audio removed) which in the end would look like:

0       1       2
video|AAAAAAA|BBBBBBB|
audio|XXXXXXX|ZZZZZZZ|
1

If your video has fixed frame rate, you probably mean by “frozen part” the part with the same frame repeated many times.

To remove duplicate frames you may apply the mpdecimate filter.

1
  • Thanks to your input I have found this question on Stackoverflow which explains how to use it. Unfortunately using the command ffmpeg -i in.mkv -vf mpdecimate out.mkv reduces the file size considerably but does not cut away the duplicated frames: the video length remains the same. Oct 6 '19 at 9:43
0

What you need in addition to remove the frozen parts is setpts. Keep in mind that mpdecimate works only on the video stream, so you have to remove the audio because is not going to be synced.

ffmpeg -i video.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB -an video-fixed.mp4
New contributor
Ivaylo Hristov is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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