r/ffmpeg • • 5d ago

speeding up / time lapse multiple videos

Hi, I am trying to condense 24 hours of video into (for example) 2 minutes - so a factor of 720. My source is a collection of 10 minute .mkv recordings, (made by AgentDVR from a Wyze Cam v3 via go2rtc). I have tried compressing each video using both of the methods described here
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
then concatenating them using ffmpeg -f concat -i list.txt -c copy etc.
The result is a video with jerky motion - each component video is sped up but there seems almost to be a pause between them.

Is there a way to do this and get a smooth output, or is this doomed?

The alternative is to concatenate the raw input videos into one and then compress that. That is probably a better way to do it, but I was hoping to avoid this, as the concatenated file would be at least 10GB.

2 Upvotes

5 comments sorted by

1

u/NoComment_4321 3d ago

I have found a reasonably satisfactory approach - extract .jpg frames at appropriate intervals (looping through each video)

for input in *.mkv; do
let c+=1
ffmpeg -i $input -vf fps=1/$timelapse ~/Media/frames/frame_$c_%04d.jpg
done

and then list them and concat them into one video
ffmpeg -f concat -i list.txt -c:v libx264 -r 25 ~/Media/output.mp4

1

u/Sopel97 4d ago edited 4d ago

Just -f concat the inputs? I don't understand why you'd be doing it only after reencoding as a second pass.

1

u/doczenith1 4d ago edited 1d ago

My method is to use lossless cut (I think that's the software,not at home right now) to merge the original files into a single file (this basically is a drag and drop vs inputting file names into a text file for ffmpeg to concatenate). I then use a spreadsheet I created to figure out the input values I need for my target video length.

Assuming the wyze videos are 20 fps this command will give you a smooth 2 minute file at 60 fps.

.\ffmpeg -i filename .mp4 -vf "select='not(mod(n,210))',setpts=0.00158730158730159*PTS" -r 60 -an -c:v libx265 -crf 28 filename TL.mp4

or this for 2 minutes at 30 fps.

.\ffmpeg -i filename .mp4 -vf "select='not(mod(n,420))',setpts=0.00158730158730159*PTS" -r 30 -an -c:v libx265 -crf 28 filename TL.mp4"

Sorry, on my tablet and don't know how to format the command as "code".

Looks like the quotes in the command got doubled up because I added a quote before I pasted the command.

1

u/videocompress 2d ago

oh I didn't know you could just pick every Nth frame with select like that, I would've only messed with setpts. does it still have to decode the whole 24h of footage though? curious roughly how long that took you

1

u/doczenith1 1d ago

Not the OP so not sure how long it took them. I just converted a 10 hour 4K video at 20 fps to a 1 minute time lapse at 20 fps using this command on a i7-14700K cpu and it took 58 minutes.

.\ffmpeg -i TestFile.mp4 -vf "select='not(mod(n,600))',setpts=0.00166666666666667\*PTS" -r 20 -an -c:v libx265 -crf 28 TestFileTL.mp4