Changes between Version 9 and Version 10 of How to speed up / slow down a video


Ignore:
Timestamp:
Feb 10, 2015, 9:05:54 PM (4 years ago)
Author:
slhck
Comment:

mostly copyedit

Legend:

Unmodified
Added
Removed
Modified
  • How to speed up / slow down a video

    v9 v10  
    11= Speeding up/slowing down video =
    22
    3 You can change the speed of your video using [http://ffmpeg.org/ffmpeg.html#asetpts_002c-setpts 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 :)
     3You can change the speed of a video stream using the [http://ffmpeg.org/ffmpeg.html#asetpts_002c-setpts setpts] video filter.
    44
    5 To speed up your video, you can type:
     5To double the speed of the video, you can use:
    66{{{
    77ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv
    88}}}
    99
    10 Note that this method will drop frames to achieve your desired speed.  You can avoid dropping frames by specifying a higher "output frame rate" than the input, for example, to go from an input of 4 to one that is sped up to 4x that (16 fps):
     10The filter works by changing the presentation timestamp (PTS) of each video frame. For example, if there are two succesive frames shown at timestamps 1 and 2, and you want to speed up the video, those timestamps need to become 0.5 and 1, respectively. Thus, we have to multiply them by 0.5.
    1111
     12Note that this method will drop frames to achieve the desired speed.  You can avoid dropped frames by specifying a higher output frame rate than the input. For example, to go from an input of 4 FPS to one that is sped up to 4x that (16 FPS):
    1213{{{
    1314ffmpeg -i input.mkv -r 16 -filter:v "setpts=0.25*PTS" -an output.mkv
    1415}}}
    1516
    16 
    17 To slow down your video, you can type:
     17To slow down your video, you have to use a multiplier greater than 1:
    1818{{{
    1919ffmpeg -i input.mkv -filter:v "setpts=2.0*PTS" output.mkv
     
    2222== Speeding up/slowing down audio ==
    2323
    24 You can speed up or slow down *audio* with the atempo audio filter. To double the speed of audio:
    25 
     24You can speed up or slow down audio with the [http://ffmpeg.org/ffmpeg-all.html#atempo atempo] audio filter. To double the speed of audio:
    2625{{{
    2726ffmpeg -i input.mkv -filter:a "atempo=2.0" -vn output.mkv
     
    2928
    3029The atempo filter is limited to using values between 0.5 and 2.0 (so it can slow it down to no less than half the original speed, and speed up to no more than double the input). If you need to, you can get around this limitation by stringing multiple atempo filters together. The following with quadruple the audio speed:
    31 
    3230{{{
    3331ffmpeg -i input.mkv -filter:a "atempo=2.0,atempo=2.0" -vn output.mkv
     
    3533
    3634Using a complex filtergraph, you can speed up video and audio at the same time:
    37 
    3835{{{
    3936ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mkv