FFMPEG | How to encode a video to make it faster

5,803

Solution 1

Speeding up/slowing down video

You can change the speed of your video using ​the setpts video filter. The "old way" of creating timelapse or still frame was to first split up a video into individual frames, (for instance, as jpg's) then delete some and recombine the frames. Using the setpts filter is the new way and is faster and possibly less lossy.

To speed up your video from 1x to 5x, you can type:

ffmpeg -i input.mkv -vf "setpts=0.2*PTS" -an output.mkv

Source: FFmpeg - how to speed up / slow down a video

Solution 2

 

Change Video Speed

 

Speed Up(5x)

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.2*PTS[v];[0:a]atempo=5.0[a]" -map "[v]" -map "[a]" output.mp4
  • Here, setpts=0.2, atempo=5.0

Slow down(5x)

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=5.0*PTS[v];[0:a]atempo=0.2[a]" -map "[v]" -map "[a]" output.mp4
  • Here, setpts=5.0, atempo=0.2

setpts:

  • If you want to speed up the video 2x, setpts will be 0.5(1/2). On the other hand, if you want to slow down the video 2x (0.5 of the normal speed), setpts will be 2.0 (1/0.5)

  • If you want to speed up the video 5x, setpts will be 0.2(1/5). On the other hand, if you want to slow down the video 5x (0.2 of the normal speed), setpts will be 5.0 (1/0.2)

atempo:

  • If you want to speed up the video 2x, atempo will be 2.0(1x2.0). On the other hand, if you want to slow down the video 2x (0.5 of the normal speed), atempo will be 0.5 (1x0.5)

  • If you want to speed up the video 5x, atempo will be 5.0(1x5). On the other hand, if you want to slow down the video 5x (0.2 of the normal speed), atempo will be 0.2 (1x0.2)

Share:
5,803
Another.Chemist
Author by

Another.Chemist

Ph.D. in chemistry.

Updated on September 18, 2022

Comments

  • Another.Chemist
    Another.Chemist almost 2 years

    Good day people,

    I was wondering how to encode a video from a speed of 1 x to a one of 5 x, using ffmpeg.

    Thanks in advance for any suggestion.

  • Csabi Vidó
    Csabi Vidó over 10 years
    It should be worth noting that Ubuntu ships avconv which is somewhat incompatible to the original and not deprecated ffmpeg. It seems to work fine with ffmpeg. As shown in the link from the answer to speed up audio and video the -filter_complex option has to be used... with ffmpeg. +1 :)
  • maracuja-juice
    maracuja-juice over 2 years
    Note: This does not speed up audio, only the video. Use atempo aswell for speeding the audio up. See the other answers for that.