I have a bunch of audio files from each of which I need to cut out the last 1 second. The audio files are of arbitrary lengths.

What is the best tool/way to do this?

I am somewhat familiar with ffmpeg, but AFAIK, it does not have a direct option to do this (the starting and ending times have to be provided with -ss and -to).

3 Answers 3


You have to use a roundabout approach. Ingest the file twice, and offset the timestamps of the 2nd input by the duration at the end you wish to trim. Then pipe both streams to another ffmpeg instance with -shortest set. In the 2nd ffmpeg instance, save only the stream from the 2nd input.

ffmpeg -i in.mp3 -itsoffset 1 -i in.mp3 -map 0:a:0 -map 1:a:0 -c copy -shortest -f nut - | ffmpeg -f nut -i - -c copy -map 0:1 out.mp3


You can use mediainfo to get the duration (in ms) and then cut to duration - 1:

duration=$(mediainfo FILE.mp3 --Inform="Audio;%Duration%")
ffmpeg -to $(($duration / 1000 - 1)) -i FILE.mp3 -c copy FILE_NEW.mp3

Inspired by answers to other questions on this site, I was also able to make something up. This command can be passed to find as an exec option

ffmpeg -i FILE1.wma -ss 0 -to $(echo $(ffprobe -i FILE1.wma -show_entries format=duration -v quiet -of csv="p=0") - 1 | bc) -c copy FILE2.wma

The part in the middle $(echo $(ffprobe -i FILE1.wma -show_entries format=duration -v quiet -of csv="p=0") - 1 | bc) first gets the desired duration. The piping to bc is to compute in floating format. The output of this is then passed as the argument to -to in the main command.

To break down the long single line command above, for ease of comprehension:

    ffmpeg -i FILE1.wma -ss 0 -to
        $(ffprobe -i FILE1.wma -show_entries format=duration -v quiet -of csv="p=0") 
        - 1 | bc
    -c copy FILE2.wma

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .