3

I need a simple (preferably command line based) tool to extract a segment from some existing mp3 file.

audacity is much too complex for me.

Ideally, I would like a command like

extract-mp3-segment --from 1:20 --to 2:40 --output myoutput.mp3 frominput.mp3

where 1:20 is the start time 1 minute 20 seconds

where 2:40 is the end time i.e. 2 minutes 40 seconds

where myoutput.mp3 is the resulting mp3 sound file (to create)

where frominput.mp3 is the large original mp3 sound file

This is on some old Ubuntu 14.04.5 distribution, x86-64

(the motivation is to extract small religious songs for a funeral, I managed to download the file (from Youtube) and to convert them to mp3)

addenda

Actually I found and used cutmp3

1 Answers1

4

Using ffmpeg (or avconv):

ffmpeg -ss 00:01:20 -t 00:01:20 -i /path/to/input.mp3 -acodec copy /path/to/output.mp3

which -ss determines start point and -t determines duration(rather than end time)

MortezaE
  • 463
  • 3
  • 7
  • 1
    I had to put -i /path/to/input.mp3 before -acodec copy otherwise I had the error Unknown decoder 'copy'. In fact I even put it in front of the other options. – Ludovic Kuty Dec 21 '22 at 10:01
  • @LudovicKuty same here, edited. Though I don't know why it don't work that way. I really don't remember if I tested it successfully before writing here. – MortezaE Feb 04 '23 at 00:25