A blazing fast CLI tool for merging audiobook files into sorted, tagged M4B files.
m4b-merge takes split audio files (MP3, M4A, or M4B) and merges them into a single, consistently tagged M4B file. Originally written in Python and rewritten in Rust, it provides high-performance processing with zero-copy merging for files of the same format, ensuring the original bitrate and sample rate are preserved.
The tool automates metadata retrieval via ASIN lookup through the Audnexus API, embeds high-resolution cover art, and maintains chapter markers from source files.
Run without installation using the GHCR image.
docker run --rm \
-v /path/to/input:/input \
-v /path/to/output:/output \
ghcr.io/djdembeck/m4b-merge:latest \
-i /input/book_folder/ -o /outputDownload the latest release for your platform from the releases page.
Requires FFmpeg installed and available in your PATH.
cargo install --path .Basic CLI interaction. Use m4b-merge --help for all available flags.
Merge all audio files in a directory into a single M4B.
m4b-merge -i input/book_folder/Provide an ASIN to automatically fetch metadata from Audnexus.
m4b-merge -i input/book_folder/ -a B012345678Specify a custom output directory and organization template.
m4b-merge -i input/book_folder/ \
-o /my/library \
-p "{author}/{series_name} {series_position} - {title}"Use --dry-run to preview operations, --num-cpus to control parallelism, and --completed-directory to move processed files.
m4b-merge -i input/book_folder/ \
--dry-run \
--num-cpus 8 \
--completed-directory /path/to/doneCheck FFmpeg installation and version.
m4b-merge --check-ffmpegThe output path is generated using the -p / --path-format template.
| Variable | Description |
|---|---|
{author} |
Author name |
{narrator} |
Narrator name |
{title} |
Book title |
{subtitle} |
Book subtitle |
{series_name} |
Series name |
{series_position} |
Series position number |
{year} |
Release year |
Default: {author}/{title}
| Code | Description |
|---|---|
0 |
Success |
1 |
Error (missing input, FFmpeg not found, processing failed) |
See CONTRIBUTING.md for guidelines on contributing to this project.
GPL-3.0