Automatically cut off multiple static parts of a video

Hi there,

There is a video like here https://www.youtube.com/watch?v=DopEEOUrxVE
And there are many parts of the video where nothing is happening.
It’s just a static and only sometimes cars are driving.
Is there a way to tell Shotcut to automatically remove these static parts and leave only the video with the cars riding?

That is not available.

Hi @nbdnnm, I asked my newly-found robot AI friend, Perplexity, and he came up with this potential solution:

Personally I don’t have sufficient skills to know how to utilize it but there are people on this forum who would know and I also would be interested to know in steps how to do it.

@nbdnnm , Update -
I learned how to use the mpdecimate filter directly on a video using ffmpeg, and found it worked with limited success.

I took a screen capture of a 2½-minute section of the video in the OP, and found that with the mpdecimate filter applied, it reduced the length by 30 seconds. However, there appear to be still static portions on the processed video.
Here’s a demo video comparing the input/output videos. Hope this helps, as a possible solution.
Otherwise it will be a matter of manually locating the static portions and cutting them out.

1 Like

PS maybe without the flashing green light by the racing track, the mpdecimate filter would work better…

@jonray that’s great! could you share the command that you used?

1 Like

Thanks you so much!
It’s really helps me with making many parts of the video.

1 Like

Sure.

ffmpeg -i input.mp4 -vf mpdecimate,setpts=N/FRAME_RATE/TB -an output.mp4

Where…

  • -i input.mp4 is your input video.
  • -vf mpdecimate,setpts=N/FRAME_RATE/TB removes static frames and fixes timing.
  • -an removes the audio (audio will not match after frames are removed).
  • output.mp4 is the new video file that will be created.

Also I forgot to say I typed:

   cd Desktop

first, because the input.mp4 video was in my desktop. (Windows 11 btw)…

Also, Shotcut includes ffmpeg.exe and related executables such as ffprobe and ffplay.

1 Like

As an experiment, I removed the green flashing light from the original video and ran the script again.
Mixed success again - it just shaved another 5 seconds off the duration of the output video (better than nothing though)…
Interesting.
Here’s the new comparison:

There are still quite a few portions of static video on the output.mp4. I wonder if that can be improved by changing the script somehow?

Another update: I asked my (rather brilliant, I think) Robot friend Perplexity for an answer to my question above. He (or maybe it’s a she… :wink:) came up with this answer. I don’t have time to experiment myself but I’m posting in case anyone finds it useful Here’s our conversation:

awesome! indeed, good trimming would require both tuning of the video and tuning of mpdecimal options

I also found this wrap around ffmpeg+mpdecimal to keep the audio GitHub - KenjiTakahashi/mpdecimate_trim: trim video clips based on mpdecimate output, keep audio synced

1 Like

Looks interesting @nbdnnm ! If I can work out how to use it…

You need to install Python and then install ffmpeg into it like python -m pip install ffmpeg
now I am waiting for the result of python ./mpdecimate_trim.py --keep ./zandvoort bimmer ring sample.mp4
where the video is a 1-hour sample of the original video

1 Like

@nbdnnm Great… please let us know how it goes…