How to slow down video playback and loop back the same audio for increased video playback time using FFmpeg?

I have a video file, for which I want to slow down the video playback by 25% without changing the audio playback speed, it will increase my video playback by 25% and I want to loop back the same audio stream for this increased video playback duration, is there any way I can tackle this problem using FFmpeg?

1 Like

Your use case is unique but achievable using FFmpeg, there is no parameter or option to accomplish the task in a single FFmpeg command, you need to follow a few steps mentioned below to get what you want.

• Separate the audio stream from the video file and loop it twice in a single audio file. -vn option allows you to separate audio from video file and the -stream_loop option allows you to loop the stream as much as time you want

ffmpeg -i video.mp4 -vn -stream_loop 2 audio_looped_twice.wav

• Create a new video file containing only the video streams from the original video file. -an option that allows you to separate video from all the streams. Slow down video playback with setpts filter which allows changing the presentation timestamp (timestamp at which the particular frame should be displayed) for each video frame.

ffmpeg -i video.mp4 -filter:v "setpts=0.75*PTS" -an video_slow.mp4

• Merge the audio stream created from step 1 and the video stream created from step 2 into a single file with -shortest which tells FFmpeg to stop the encoding/merging process as soon as the shortest stream ends.

ffmpeg -i video_slow.mp4 -i audio_looped_twice.wav -map 0:v -map 1:a -c:v copy -c:a copy -shortest -f mp4 output.mp4