2

I am working on a time lapse project currently have a couple long videos where there are parts where nothing is happening and I am wondering if there is a program that can strip out all those parts or strip out all the motion parts and put into a single file rather than me going through hours of playback and manually cutting them out.

I have read vlc can detect motion in the play back but not sure how to make use of this. This can be a solution for windows or linux.

BluGeni
  • 131

1 Answers1

2

I have been doing some experiments with ffmpeg and the mpdecimate filter.

Output is a video with only the "active" parts and I used some tricks with the FPS.

Output will play at 25fps for the player, but will be at 5fps in reallity (adjust number 5 in both setpts and first fps filters to adjust speed. If 25fps is good for you (my test video showed changes too fast for me), drop the last filter and use -map [c] instead.

If you need to adjust threshold, look at here: (f.e.: mpdecimate=hi=64*12:lo=64*8:frac=0.33)

mpdecimate would drop the frames, but the lenght is kept. With setpts you force it to calculate a fixed duration for each frame and the first fps makes it match the "current" speed defined by setpts. Last fps makes it "playable" (inserts duplicate frames to fill to the 25fps video), (5fps video on my VLC does not play very well, freezing every now and then)

ffmpeg -y -i input.mp4 -filter_complex "[0:v] mpdecimate [a] ; [a] setpts='N/(5*TB)' [b] ; [b] fps=5 [c] ; [c] fps=25 [d]" -map "[d]" -c:v libx264 ouput.mp4
NuTTyX
  • 2,716