A simple CLI tool to split MP3 files into smaller chunks. This tool recursively searches for MP3 files in a specified directory and its subdirectories, then splits them into chunks of a specified duration.
- Recursively find all MP3 files in a directory and subdirectories
- Split MP3 files into chunks of specified duration (in minutes)
- Save split files in organized subdirectories
- Command-line interface with helpful options
- Proper error handling and validation
- Clone this repository:
git clone <repository-url>
cd mp3-pipeline- Install the package in development mode:
pip install -e .The tool requires the following Python packages:
click- for the command-line interfacepydub- for audio processing
Note: pydub also requires FFmpeg to be installed on your system.
macOS:
brew install ffmpegUbuntu/Debian:
sudo apt update
sudo apt install ffmpegWindows: Download from FFmpeg official website and add to PATH.
Split all MP3 files in the current directory into 5-minute chunks:
mp3-split .Split all MP3 files in a specific directory:
mp3-split /path/to/musicSpecify custom chunk duration (10 minutes):
mp3-split /path/to/music --duration 10Use a custom output subdirectory name:
mp3-split /path/to/music --output chunksEnable verbose output:
mp3-split /path/to/music --verboseCombine options:
mp3-split /path/to/music -d 3 -o split_files -vDIRECTORY: The directory to search for MP3 files (required)--duration, -d: Duration of each chunk in minutes (default: 5)--output, -o: Name of subdirectory to save split files (default: "split")--verbose, -v: Enable verbose output--help, -h: Show help message
- The tool recursively searches the specified directory for all files ending with
.mp3 - For each MP3 file found, it checks if the file duration exceeds the chunk duration
- If the file is longer than the chunk duration, it splits the file into chunks
- Each chunk is saved in a subdirectory named after the output option (default: "split")
- Chunk files are named using the pattern:
{original_name}_part{number}.mp3
If you have:
/music/
├── podcast1.mp3 (25 minutes)
└── subfolder/
└── podcast2.mp3 (12 minutes)
After running mp3-split /music --duration 10, you'll get:
/music/
├── podcast1.mp3
├── split/
│ ├── podcast1_part001.mp3 (10 minutes)
│ ├── podcast1_part002.mp3 (10 minutes)
│ └── podcast1_part003.mp3 (5 minutes)
└── subfolder/
├── podcast2.mp3
└── split/
├── podcast2_part001.mp3 (10 minutes)
└── podcast2_part002.mp3 (2 minutes)
You can run the tool directly from the source code:
python -m mp3_pipeline.cli /path/to/musicCreate some test MP3 files and run the tool to verify functionality:
# Test with verbose output
mp3-split test_data --duration 2 --verbose- Python 3.10 or higher
- FFmpeg (required by pydub for MP3 processing)
- See
pyproject.tomlfor Python package dependencies
Add your license information here.
Add contribution guidelines here.