Speed up part of video using ffmpeg

ffmpegvideo

I'm recording screencasts and some part of the recorded screencasts I would like to speed up using a command line tool like ffmpeg.

I know that it is possible to use ffmpeg to speed up an entire video with a command like (source)

ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv

Is it possible to only apply the speedup in certain regions in the video. Eg. from 10 to 15 seconds and again from 50 to 60 seconds? Something similar seems to be possible using the program slowmoVideo.

Best Answer

Example : I want to speed up the first 4 seconds of my video.

Cut your video

ffmpeg -i input.mp4 -t 4 slow.mp4
ffmpeg -i input.mp4 -ss 00:00:04 part-2.mp4

Speed up the part

ffmpeg -i slow.mp4 -filter:v "setpts=0.5*PTS" part-1.mp4

Concatenate

ffmpeg -f concat -i <(for f in ./part-*.mp4; do echo "file '$PWD/$f'"; done) -c copy output.mp4

Resources from ffmpeg documentation: