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.

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
  • I get ] No such filter: 'mpdecimate' Error splitting the argument list: Option not found what do i need to do to fix this? – BluGeni Sep 29 '14 at 20:32
  • I missed quotes around [d] in -map. As for the filter, I used and current version of ffmpeg. Could you try to update yours? – NuTTyX Sep 29 '14 at 20:38
  • ok perfect its running now, it looks like it will take a while to complete. I will report back after its done. – BluGeni Sep 29 '14 at 21:14
  • 2
    If you use -vsync 2, you can make a VFR output file. (ffmpeg default is CFR mode for mp4, VFR for mkv). Then you shouldn't need to dup frames with the fps filter. Nice idea with using setpts to skip no-motion sections. – Peter Cordes Mar 3 '15 at 22:09
  • 1
    also, all of those filters are 1 input, 1 output. In this case, you don't actually need filter_complex, or named inputs/outputs. Just ffmpeg in.mkv -vf "mpdecimate, setpts='N/(5*TB)' -preset slow out.mkv should work. (you don't need -map, because ffmpeg maps the output of your video filtergraph by default.) – Peter Cordes Mar 3 '15 at 22:14

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.