split-mp3

A command line tool to split mp3 files

Usage no npm install needed!

<script type="module">
  import splitMp3 from 'https://cdn.skypack.dev/split-mp3';
</script>

README

Split mp3

Split mp3 files from the command line.

Quick start

So you have a long mp3 file you want to split, let's say full.mp3.

You have to create a file for the tracks, let's say tracks.txt.

In this file, you will have to specify the start time and the title for each track, using the following format:

0:00 This is the first track
1:23 Second track here
4:56 I am the third one
7:00 Fourth time is a charm
12:34 Take five
56:00 Six is the last one

Once the tracks file is ready, you can split your long mp3 file:

npx split-mp3 full.mp3 tracks.txt

This will create six files:

01 - This is the first track.mp3
02 - Second track here.mp3
03 - I am the third one.mp3
04 - Fourth time is a charm.mp3
05 - Take five.mp3
06 - Six is the last one.mp3

Tracks file gotchas

A few things to note regarding the tracks file:

  • The start times for tracks must use the MM:SS or HH:MM:SS format. Note that the separator is :.

  • The start times and the titles must be separated by exactly one space.

  • The track titles must not contain funky characters, they will be used in file names.

    Also, FFMpeg will be called from a shell using a command like this:

    ffmpeg -i full.mp3 -acodec copy -ss 83 -to 296 "02 - Second track here.mp3"
    

    Command injections are possible, so be careful.

  • Blank lines and tailing white space will be ignored.

  • Leading zeros for the start times will be ignored (01:23, 01:23:45 are both accepted).

Requirements

You will need Node 12+ and npm 5.2+ to run this.

You will also need FFmpeg installed.

Contributing

If something doesn’t work, please file an issue.

If you have questions, need help, or would like to contribute, please reach out at tothab@gmail.com.

Disclaimer

I made this tool to save myself some time.

I did not have great ambitions, I did not make it beautiful, I did not do a lot of testing.

It works on my machine, which is all I needed.

It will probably work on yours, too.

License

Split mp3 is licensed under MIT.