baskak
baskak

Reputation: 1

Timelapse (1/6 fps) from slo-mo (240 fps) with ffmpeg

I recorded slo-mo video on an iPhone SE (2) by mistake instead of timelapse.

I know there's a lot of answers to this question here, but I'm trying again and again and always something's wrong (like a video that has a correct total no. of frames, but lasts 3 hours and is basically a freeze :D ) My recent command was

ffmpeg -i IMG_2174.MOV -vf framestep=1440,setpts=N/120/TB -c:v libx264 -preset slow -crf 22 -an -r 30 IMG_2174.timelapse.MOV

but it resulted in a one-second-long video, so way over-timelapsed. Should be several seconds IINM. The source video is 30 minutes long @240fps, 17GB. Thx.

Upvotes: 0

Views: 1080

Answers (2)

kesh
kesh

Reputation: 5533

Here is the explanation for OP's self-answer.

ffmpeg -i IMG_2174.MOV 
       -vf framestep=1440,setpts=N/30/TB 
       -r 30 -c:v libx264 -preset slow -crf 22 -an IMG_2174.timelapse.MOV

Given input video at 240 fps cfr:

  1. framestep=1440 keep every 1440th frame, yielding 240/1440 = 1/6 fps
  2. setpts=N/30/TB speeds up the video by x180 (30 / 1/6)
  3. -r 30 output option: match the new pts interval set above

For a vfr video, framestep=1440 likely results in incorrect timing (though on the average correct). For such video, replace the framestep filter with fps=1/6 filter so it picks the frames based on pts rather than frame count.

[edit note: iPhone's slo-mo recording does keep 240fps cfr so the OP's solution is 100% correct, edited down just to mention a vfr-correct approach]

Upvotes: 0

baskak
baskak

Reputation: 1

This command seems to do the trick:

ffmpeg -i IMG_2174.MOV -vf framestep=1440,setpts=N/30/TB -c:v libx264 -preset slow -crf 22 -an -r 30 IMG_2174.timelapse.MOV

Upvotes: 0

Related Questions