Search code examples
audioffmpegmp3

Using ffmpeg to split MP3 file to multiple equally sound length files


How to use the command line tool ffmpeg on Windows to split a sound file to multiple sound files without changing the sound properties same everything each one is fixed 30 seconds length. I got this manual example from here:

ffmpeg -i long.mp3 -acodec copy -ss 00:00:00 -t 00:00:30 half1.mp3
ffmpeg -i long.mp3 -acodec copy -ss 00:00:30 -t 00:00:30 half2.mp3

But is there a way to tell it to split the input file to equally sound files each one is 30 seconds and the last one is the remaining what ever length.


Solution

  • You can use the segment muxer.

    ffmpeg -i long.mp3 -acodec copy -vn -f segment -segment_time 30 half%d.mp3
    

    Add -segment_start_number 1 to start segment numbering from 1.