Changes between Version 16 and Version 17 of How to speed up / slow down a video


Ignore:
Timestamp:
Feb 11, 2021, 11:57:01 AM (4 months ago)
Author:
veikk0
Comment:

lossless method

Legend:

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

    v16 v17  
    11= Speeding up/slowing down video =
    22
    3 You can change the speed of a video stream using the [http://ffmpeg.org/ffmpeg-all.html#setpts_002c-asetpts setpts] video filter. Note that in the following examples, the audio stream is not changed, so it should ideally be disabled with `-an`.
     3The speed of a video stream can be changed by changing the presentation timestamp (PTS) of each video frame. This can be done via two methods: using the [http://ffmpeg.org/ffmpeg-all.html#setpts_002c-asetpts 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.
    44
    5 To double the speed of the video, you can use:
     5Note that in the following examples, the audio stream is not changed, so it should ideally be disabled with `-an`.
     6
     7== raw bitstream method ==
     8
     9This method is lossless and apart from changing the timestamps, copies the video stream as-is. Use this if you require no other changes to your input video.
     10
     11First, copy the video to a raw bitstream format.
     12
     13For H.264:
     14{{{
     15ffmpeg -i input.mp4 -map 0:v -c:v copy -bsf:v h264_mp4toannexb raw.h264
     16}}}
     17
     18For H.265:
     19{{{
     20ffmpeg -i input.mp4 -map 0:v -c:v copy -bsf:v hevc_mp4toannexb raw.h265
     21}}}
     22
     23Then generate new timestamps while muxing to a container:
     24{{{
     25ffmpeg -fflags +genpts -r 30 -i raw.h264 -c:v copy output.mp4
     26}}}
     27
     28Change the value of `-r` to the desired playback frame rate.
     29
     30== setpts filter ==
     31
     32To double the speed of the video with the setpts filter, you can use:
    633{{{
    734ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv
     
    2047}}}
    2148
    22 == Smooth ==
     49=== Smooth ===
    2350
    2451You can smooth out slow/fast video with the [http://ffmpeg.org/ffmpeg-filters.html#minterpolate minterpolate] video filter. This is also known as "motion interpolation" or "optical flow".