Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Speed up part of video using ffmpeg

Tags:

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.

like image 975
midtiby Avatar asked Jan 21 '15 18:01

midtiby


People also ask

How do I speed up a video using FFmpeg?

Speeding up/slowing down video This can be done via two methods: using the ​setpts video filter (which requires re-encoding) or by erasing the timestamps by exporting the video to a raw bitstream format and muxing to a container while creating new timestamps.

How do I change frame rate in FFmpeg?

How to change the frame rate. There are two ways to change the output frame rate: With the -r option used as an output option. With the ​fps filter.

What is overlay FFmpeg?

FFmpeg offers the overlay filter as a way to overlay images (or even other videos) onto video streams. To centre overlay/watermark on a video, use this command: ffmpeg -i inputvideo.avi -i watermarklogo.png -filter_complex \ "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy output.flv.


1 Answers

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:

  • Concatenate
  • Seeking
  • Speeding up/slowing down video
like image 86
youyoup Avatar answered Oct 04 '22 10:10

youyoup