Michael Ben Haym
Michael Ben Haym

Reputation: 59

How to apply an ffmpeg audio effect only on a part of a video?


My question is how can I apply an ffmpeg audio effect only on a certain part of a video and not on 100% of the video.
I have for example the following command:

ffmpeg -i input.mp4 -filter_complex "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75" output.mp4

this command works perfectly for me but if for example I have a video of 30 seconds and want the effect to be applied only on seconds 20-25, how do I do it?
Thanks!

Upvotes: 0

Views: 333

Answers (1)

atrim, concat:

ffmpeg -i input.mp4 -filter_complex "
[0:a]atrim=0:20[a1];
[0:a]atrim=20:25,asetpts=PTS-STARTPTS[a2];
[0:a]atrim=25:31,asetpts=PTS-STARTPTS[a3];
[a2]afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75[b2];
[a1][b2][a3]concat=n=3:v=0:a=1
" -c:v copy -c:a aac -q:a 4 output.mp4

Upvotes: 2

Related Questions