Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple fadeIn/fadeOut effects in one audio file with ffmpeg

Tags:

ffmpeg

audio

I have some problem to add several fade effects to one audio file. When I try to use a command like this:

ffmpeg -y -i /home/user/video/test/sound.mp3 -af "afade=t=in:ss=0:d=3,afade=t=out:st=7:d=3,afade=t=in:st=10:d=3,afade=t=out:st=17:d=3,afade=t=in:st=20:d=3,afade=t=out:st=27:d=3" /tmp/test.mp3

then my output audio file has a fadein and fadeout applied only once. All the next effects don't get applied. Is there any possible way to apply several fade effects to the same audio file? Also, what is the difference between ss and st parameter in this command?

like image 770
farw Avatar asked Apr 22 '14 12:04

farw


1 Answers

The problem is that after fading out the audio you are trying to fade in the silence.

The solution is to disable the fade out filter when you want to start fading in.

You can achieve that with Timeline Editing to enable the filters for a particular amount of time.

The following example works just fine:

ffmpeg -i input.mp3 -af "afade=enable='between(t,0,3)':t=in:ss=0:d=3,afade=enable='between(t,7,10)':t=out:st=7:d=3,afade=enable='between(t,10,13)':t=in:st=10:d=3,afade=enable='between(t,13,16)':t=out:st=13:d=3" -t 16 output.mp3
like image 71
matthewd Avatar answered Oct 07 '22 11:10

matthewd