timelapse aka speeding up with ffmpeg

These days I’m recording my work in the studio using a timelapse function in my Panasonic TM700 HD camera. So it happened that I forgot to turn on the the function (needs to be turned on everytime you start recording) which usually records one frame every 10 seconds, so I ended up with a “normal” recording and wanted to convert that to what camera usually does. Ffmpeg to the rescue! To do some frame manipulation a video filter “setpts” is what one needs. Gathering knowledge online with help of two pages: to speed up / slow down a video

So, supposedly, the right way to change video speed using ffmpeg is by adjusting the “presentation time stamp” (PTS). This adjusts frames’ metadata related to how long each is displayed—exactly what you want.

this is the crucial piece of code that needs to be passed to ffmpeg:

-filter:v "setpts=2.0*PTS"

Or a more practical example using fraction – if original framerate is 25 frames per second I only need evert 250th one:

$ ffmpeg -i INPUTFILE.mkv -filter:v "setpts=(1/250)*PTS" OUTPUTFILE.mkv

My final conversion was from full-HD .mts to 720p .webm and to mp4:

$ ffmpeg -i INPUT.mts -filter:v "setpts=(1/250)*PTS" -s 1280x720 -c:v libvpx -crf 5 -b:v 8M -an OUTPUT.webm
$ ffmpeg -i INPUT.mts -filter:v "setpts=(1/250)*PTS" -s 1280x720 -c:v libx264 -preset slow -crf 10 -an OUTPUT.mp4