Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is a Linux audio MP3 puzzle that has been bugging me for awhile:

How to trim the beginning few seconds off an MP3 audio file? (I can't get ffmpeg -ss to work with either 00:01 or 1.000 format)

So far, to do what I want, I resort doing it in a GUI manner which is maybe slower for a single file, and definitely slower for a batch of files.

share|improve this question
An update. Later, I stumbled upon the fact that ffmpeg is very picky about the --ss time format, and I was able to most easily trim off the first 9 seconds for instance by specifying -ss 00:00:09 (note that it needs all 3 numbers in hh:mm:ss format) The version I was using may be old... FFmpeg version SVN-r18709, Copyright (c) 2000-2009 Fabrice Bellard, et al. – Mark Hudson Jun 29 '12 at 6:02
up vote 4 down vote accepted

For editing mp3's under linux, I'd recommend sox. It has a simple to use trim effect that will do what you ask for (see man sox for datails - search (press/) for "trim start").

You didn't mention it, but if your aim is just to remove the silence at the beginning of files, you will find silence effect much more useful (man sox, search for "above-periods")

share|improve this answer
Thanks, awesome: it worked. I ended up using the trim for simplicity. The only downer was sox FAIL formats: can't open output file 'blah.mp3': SoX was compiled without MP3 encoding support --so, re-enter ffmpeg :/ – Mark Hudson Aug 5 '11 at 19:27
That seems unusual. On my computer, it works without a problem with mp3s. It is a matter of build-time configuration. How did you install it? – rozcietrzewiacz Aug 5 '11 at 23:03
@rozcietrzewiacz, if you install sox from a distribution repository you will most likely get sox without MP3 support (because of license issues). For example on Fedora 17: no handler for file extension mp3 – maxschlepzig Jun 10 '13 at 13:36

You could try using mp3splt, which can split MP3 and Ogg files and has the advantage that it does not re-encode the file, thereby avoiding quality loss.

share|improve this answer
I like it; thanks. It is simple, and yet has plenty of options... For example: here is the command I just used, which adds the split times to the filename: mp3splt "$file" 4.12 27.55.7 ... It allows custom output name formatting and multiple split points. – Peter.O Dec 20 '11 at 8:05

Make sure that your time specifications start with hours.

To cite the ffmpeg man page:

position may be either in seconds or in "hh:mm:ss[.xxx]" form

That means that when you choose the 2nd syntax only the .xxx part is optional. Else ffmpeg might mis-parse it as seconds.

Same goes for duration:

duration may be a number in seconds, or in "hh:mm:ss[.xxx]"

Another pitfall is the ordering of ffmpeg arguments (e.g. the -ss/-t options for an input file have to come before the -i option).


$ wget http://traffic.libsyn.com/twiv/TWiV179.mp3
$ ffmpeg -ss 1:05:59.3 -t 00:02:03.9 -i TWiV179.mp3 -acodec copy \

With the specification -ss 1:05:59.3 -t 2:03.9 you would get a different result (i.e. a 2 second long piece).

(Tested on Fedora 17 with ffmpeg version 0.10.7.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.