How to change video and audio speed using FFmpeg

In this guide, we will see how to Modify video and audio speed using FFmpeg filters.

Video speed

To change the speed of the video file, we can use the setpts (set presentation timestamp) filter.

Filter Description: Changes presentation timestamp (PTS) of input frames.

Filter Syntax:


List of available variables which we can use in expression:

FRAME_RATEframe rate, only defined for a video with a constant frame
INTERLACEDtell is the current frame is interlaced
Ncount of the input frame, starting from 0
NB_CONSUMED_SAMPLESnumber of consumed samples, without the current frame (only audio)
NB_SAMPLESnumber of samples in the current frame (only audio)
POSoriginal frame position in the file, or undefined if undefined for the current frame
PREV_INTprevious input time in seconds
PREV_INPTSprevious input PTS
PREV_OUTPTSprevious output PTS
PREV_OUTTprevious output time in seconds
PTSpresentation timestamp in input
SAMPLE_RATEaudio sample rate
STARTPTSPTS of the first frame
STARTTtime in seconds of the first frame
Ttime in seconds of the current frame
TBtime base

Each video frame contains a header with a timestamp value, the difference between 2 frames in sequence is 1/fps, for instance if fps is 25, the difference is 0.04 second. to speed up the video this time difference must be smaller and for a lower speed it must be bigger. For example, to watch the video 3-times faster, the input timestamp is divided by 3 and the command is:

ffplay -i input.mpg -vf setpts=PTS/3

To watch the video in a 3/4 speed, the input timestamp is divided by 3/4 and we can use the command:

ffplay -i input.mpg -vf setpts=PTS/(3/4)

Audio speed

To change the tempo of the audio, we can use the special atempo filter.

Filter Description: Changes audio tempo – the speed of the audio stream.

Filter Syntax:


Description of parameter:

tempo: float number from the range 0.5 – 2.0, values less than 1.0 slows down and values over 1.0 speed up the tempo, the default value is 1.0

for example to hear the input audio with 2-times faster speed, we can use the command:

ffplay -i film.mp3 -af atempo=2

To hear this audio in a half tempo, we can use the atempo=0.5 setting and if the speed change is not sufficient, the filter can be applied more times.

ffplay -i film.mp3 -af atempo=0.5

Slow down audio to 90% tempo:

ffplay -i film.mp3 -af atempo=0.9

To speed up audio to 140% tempo:

ffplay -i film.mp3 -af atempo=1.40

Published by


Codecs Lover

Leave a Reply