Home

mp3 cutting and combining

This guide will show you how to split and combine MP3 files using FFmpeg, a powerful command-line tool. We’ll use a simple method that doesn’t re-encode the audio, which means no quality loss and lightning-fast processing.


Part 1: How to Split an MP3 File

You can split a single MP3 file into two or more parts by specifying a start and end time. The key is to use the -acodec copy option, which copies the audio data without re-encoding it.

Splitting the First Part

This command cuts a file from the beginning to a specified timestamp.

ffmpeg -i input_file.mp3 -ss 00:00:00 -to 00:01:30 -acodec copy first_part.mp3

Splitting the Second Part

This command cuts the remainder of the file, starting from where the first part ended.

ffmpeg -i input_file.mp3 -ss 00:01:30 -acodec copy second_part.mp3

Part 2: How to Combine and Multiply an MP3 File

Combining multiple MP3 files into one is done using the concat demuxer. This method also avoids re-encoding to maintain quality.

Step 1: Create a List File

First, you need a text file that lists all the MP3 files you want to combine. Let’s call it mylist.txt. Each line should specify a file using the format file 'filename'.

To combine multiple different files, create mylist.txt manually:

file 'intro.mp3'
file 'song.mp3'
file 'outro.mp3'

Step 2: Combine the Files

Use the list file as the input for FFmpeg to perform the concatenation.

ffmpeg -f concat -safe 0 -i mylist.txt -c copy combined_file.mp3

Combining a single file

Step 1a: Create a list file to multiply a single file

To multiply one file and combine it with itself, you can quickly generate the list from the command line. This example repeats a file 10 times:

for i in {1..10}; do echo "file 'your_file.mp3'"; done > repeat.txt

Step 2a: Combine the Files

This command uses the repeat.txt file to tell FFmpeg to combine the files into a single output file without re-encoding.

ffmpeg -f concat -safe 0 -i repeat.txt -c copy output.mp3

The new combined file will be named output.mp3.

Tags: Mp3, Music, Linux, Cli