Slowing down audio of a video using FFMPEG

3.7k views Asked by At

Good day. Before anything else, I would like to say that I am a newbie with regards to video filters on FFMPEG. So please bear with me, :) Thanks in advance..

Anyways, I am trying to slow down a video clip that will be embedded and played within my delphi project. So far, slowing the video works fine by using the setpts filter. here's my partial code:

FFPlayer.VideoFilters := Format('setpts=(1/' + FloatToStr(FSpeed) + ')*PTS, nativeeq=%d:%d:%d:%d, nativehue=%d:%d:%d:%d',
  [0, 0, 0, 0, 0, 0, 0, 0]);

where FSpeed is a changing value that ranges 0.5 - 2.5. With this code, the video capture speeds up or slows down, but the audio doesn't. So as I was searching for the code to slow down the audio, I came across this link that provides the filter codes for speeding up or slowing down the video capture and audio. A line there mentioned that the filter code to slow down the audio and video capture at the same time is:

ffmpeg -i input.mkv -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mkv

I tried adding "atempo=2.0" to my partial code making it:

FFPlayer.VideoFilters := Format('setpts=(1/' + FloatToStr(FSpeed) + ')*PTS, atempo=2.0, nativeeq=%d:%d:%d:%d, nativehue=%d:%d:%d:%d',
  [0, 0, 0, 0, 0, 0, 0, 0]);

but video didn't show up at all.

I am hoping you could enlighten me with this one. Thanks.

1

There are 1 answers

0
JustAGuy On

Not quite sure what you did there but this worked for me:

ffmpeg -i VID_20150216_185018.mp4 -filter_complex setpts=4*PTS;atempo=0.5,atempo=0.5 output.mp4

For more more on the atempo filter please refer to the docs.