1

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?

cannyboy
  • 24,180
  • 40
  • 146
  • 252
  • 1
    I think ffmpeg does not have the special command to cut/fade the file "from the end" so you will need the whole script to do that (first use some tool like ffprobe to find the duration of the audio and then use this knowledge to construct ffmpeg command). The ffmpeg command to do the cut and fade in/out in your example will look like that: `ffmpeg -ss 00:00:30 -to 00:01:40 -i input.mp3 -af "afade=t=in:st=0:d=5,afade=t=out:st=65:d=5" -c:a libmp3lame output.mp3` – Lex Feb 16 '22 at 16:09
  • 1
    It is unfortunate that it has `-sseof` but not `-toeof` option – kesh Feb 16 '22 at 16:36

1 Answers1

2

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

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60