1

I am able to do slow motion video using following command (found this at How to use slow motion effect in a specific time interval with ffmpeg):

ffmpeg -i input.mkv -filter_complex \
"[0:v]trim=0:10,setpts=PTS-STARTPTS[v1]; \
 [0:v]trim=10:30,setpts=PTS-STARTPTS[v2]; \
 [0:v]trim=start=30,setpts=PTS-STARTPTS[v3]; \
 [v2]setpts=PTS/0.5[slowv]; \
 [v1][slowv][v3]concat=n=3:v=1:a=0[out]" \
-map [out] output.mp4

but i also want to have same effect on audio such as that duration between 10-30 secs have slow motion audio else all other audio parts have normal speed.

Also the above command increase the video length, can some how it can be reduce to actual video length ?

Kindly someone help me out how to do this ?

shrhawk
  • 159
  • 2
  • 6

1 Answers1

1

You can't slow down a video and preserve its original length. You'll have to trim off some portion to do so.

To slow down the audio as well, do this

ffmpeg -i input.mkv -filter_complex \
"[0:v]trim=0:10,setpts=PTS-STARTPTS[v1]; \
 [0:v]trim=10:30,setpts=(PTS-STARTPTS)*2[v2]; \
 [0:v]trim=start=30,setpts=PTS-STARTPTS[v3]; \
 [0:a]atrim=0:10,asetpts=PTS-STARTPTS[a1]; \
 [0:a]atrim=10:30,asetpts=PTS-STARTPTS,atempo=0.5[a2]; \
 [0:a]atrim=start=30,asetpts=PTS-STARTPTS[a3]; \   
 [v1][a1][v2][a2][v3][a3]concat=n=3:v=1:a=1[v][a]" \
-map [v] -map [a] output.mp4
Gyan
  • 34,439
  • 6
  • 56
  • 98
  • thanks @Mulvya is there any ratio (formula) between atempo(audio) and setpts(video)? for example if i want to slow down video **30** percent than what should be the value of atempo in this case ? – shrhawk May 04 '16 at 08:07
  • Slowing down 30% means playing it at 70% of original speed, so `atempo=0.70` – Gyan May 04 '16 at 08:20