setpts filter
To double the speed of the video with the setpts filter, you can use:
1 |
ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv |
The 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.
Note 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):
1 |
ffmpeg -i input.mkv -r 16 -filter:v "setpts=0.25*PTS" output.mkv |
To slow down your video, you have to use a multiplier greater than 1:
1 |
ffmpeg -i input.mkv -filter:v "setpts=2.0*PTS" output.mkv |