Snipping and adding fade in / out effects using ffmpeg

While you might think ffmpeg is well documented on Linux given its relative maturity, I found the docs provided very confusing and even misleading as some filters (like “afade”) referenced in many examples weren’t even availble on Ubuntu 12.04 LTS. (check your own version using the “-filters” ffmpeg argument: After much searching and googling, I arrived at the solution below and I’m documenting it here for my own use and posterity 😉

Get the latest static ffmpeg build to make sure you have the “afade” filter available for Linux:

http://ffmpeg.gusari.org/static/

Extract ffmpeg to somewhere in your path (I use $HOME/bin). 

Extract 70 seconds of audio, starting at 60 seconds into the file:

ffmpeg -i test.mp3  -ss 60 -t 70 test01.mp3

Add the fade-in effect (4 seconds):

ffmpeg -i test01.mp3 -af "afade=t=in:ss=0:d=4" test02.mp3

Add the fade-out effect (5 seconds, starting at 65 seconds) to the new file:

ffmpeg -i test02.mp3 -af "afade=t=out:st=65:d=5" test03.mp3

I guess this could be done in a better way, combining the snipping and the filtering in one go, but I couldn’t figure out the correct filter / snipping syntax. If you do, please comment.

 

5 thoughts on “Snipping and adding fade in / out effects using ffmpeg

  1. Tycho

    Also if you do not want to silence first 60 seconds, use something like:
    ffmpeg -i INPUT -af afade=enable=’between(t,60,130)’:t=in:st=60:d=4,afade=t=out:st=125:d=5 OUTPUT

  2. hoover Post author

    Thanks Tycho, so is there a way to seek / select a portion of the file *and* fading the ends of the new file in one go?

    Cheers, Uwe

  3. Tycho

    Second example with “enable” should apply effect only from 60 to 130 seconds of audio. So you do not get silence in first 60 seconds. This way there is no need for pointless split of files in numerous parts. Do you tried 2nd example? You may need to add extra escaping for ‘,’ with ‘\’.

    ‘enable’ option just tells for what time interval audio fade effect will be applied.

  4. satish

    i need ffmpeg command to con-cat two videos with fade-out at the end of 1st video and fade-in at the 1st sec of sdecond video ..and its should support audio as well.
    if there any plz let me know .thank you

Leave a Reply

Your email address will not be published. Required fields are marked *