Search code examples
ffmpegsox

Cut and fade at start and end of mp3 with ffmpeg or sox


I've got a folder of mp3 files. They all vary in duration, but otherwise they're all in the same format. For a two minute file, it would look like this:

00:00 Spoken word intro
00:30 Musical intro
00:40 CONTENT
01:30 Musical outro
02:00 End

... but the mp3s can vary in duration, so a 5 minute file would have the musical outro at 04:30.

I would like to remove the first 30 secs and last 20 secs, and fade in and out (5 secs) the remaining sound. Is there a way to do this with either ffmpeg or sox?


Solution

  • I suspect you're looking for something like this:

    sox interview.mp3 out.mp3 trim 30 -20 fade 5 -0 5
    

    which trims the first 30 seconds and last 20 seconds from the audio, then fades in over the first 5 seconds and fades out over the last 5 seconds. See the answer from @WASDI here SOX and fade in and fade out for the fade result