m4b-tool
Convert audio files to M4B audiobook format
TLDR
Create an audiobook with the audio files in the input directory
Make chapters using the input files' names
SYNOPSIS
m4b-tool [GLOBAL_OPTIONS] <COMMAND> [COMMAND_OPTIONS] [ARGUMENTS]
Common commands:
merge: Combine audio files into an M4B audiobook.
re-encode: Re-encode an existing audio file.
tag: Add or modify metadata tags of an M4B file.
chapters: Manage or export chapter information.
PARAMETERS
Global Options:
-v, --verbose
Increase output verbosity.
-d, --debug
Show debug output for troubleshooting.
-f, --force
Overwrite existing files without prompting.
--dry-run
Simulate actions without making actual changes.
--skip-update
Skip checking for new m4b-tool versions.
Merge Command Options:
-o, --output-file <FILE>
Specify the output M4B filename.
-a, --audio-codec <CODEC>
Set the audio codec (e.g., aac, libopus, copy). Using 'copy' avoids re-encoding.
-b, --bitrate <BITRATE>
Set the audio bitrate (e.g., 64k, 128k).
--volume-normalization
Normalize audio volume across all input files to a consistent level.
--tag-author <AUTHOR>
Set the audiobook author tag.
--tag-title <TITLE>
Set the audiobook title tag.
--tag-genre <GENRE>
Set the audiobook genre tag.
--tag-cover <FILE>
Embed cover art from an image file (e.g., JPG, PNG).
--chapter-file <FILE>
Provide an external file for defining chapters (e.g., TXT, JSON).
--output-format <FORMAT>
Specify output container format (e.g., m4b, m4a, mp3).
--optimize
Optimize the M4B file for streaming and playback.
Re-encode Command Options:
-o, --output-file <FILE>
Specify the output filename for the re-encoded audio.
-a, --audio-codec <CODEC>
Set the audio codec for re-encoding.
-b, --bitrate <BITRATE>
Set the audio bitrate for re-encoding.
Tag Command Options:
--remove-tags
Remove all existing metadata tags from the file.
--export-cover <FILE>
Export the embedded cover art to an image file.
--export-chapters <FILE>
Export chapter information to a specified file.
Chapters Command Options:
--export <FILE>
Export chapter information from the file to a specified output file.
--format <FORMAT>
Specify the output format for exported chapters (e.g., json, txt, xml).
--import <FILE>
Import chapters into the M4B file from an external file.
DESCRIPTION
m4b-tool is a versatile command-line utility designed to simplify the creation and management of M4B audiobooks. It leverages powerful underlying tools like FFmpeg and AtomicParsley to merge multiple audio files (such as MP3s) into a single M4B file, re-encode audio, and add comprehensive metadata (author, title, genre, year, cover art, description) and chapters. It supports various input audio formats and provides options for audio normalization, custom chapter definitions, and advanced encoding settings. This makes it an essential tool for audiobook enthusiasts and creators on Linux, macOS, and Windows seeking to organize their audio libraries or convert audio collections into the M4B format.
CAVEATS
m4b-tool relies on external dependencies: FFmpeg for audio processing and AtomicParsley for metadata and chapter manipulation. These tools must be installed and accessible in your system's PATH for m4b-tool to function correctly. Processing large audio files or numerous files can be resource-intensive and time-consuming. The quality of the output M4B depends significantly on the chosen audio codec, bitrate, and the quality of the source audio.
INSTALLATION
m4b-tool is typically installed via Python's package manager pip: pip install m4b-tool. Alternatively, pre-compiled binaries are available for download from its GitHub releases page. Remember to install ffmpeg and atomicparsley separately, as they are core dependencies.
EXAMPLE USAGE
To merge an entire audiobook from a directory of MP3s into a single M4B file with metadata and cover art:
m4b-tool merge "/path/to/audiobook/parts/" \
--output-file "My Audiobook.m4b" \
--tag-author "Author Name" \
--tag-title "Book Title" \
--tag-genre "Fiction" \
--tag-cover "cover.jpg" \
--bitrate 64k \
--optimize \
--volume-normalization
HISTORY
m4b-tool emerged as a practical solution to streamline the creation of M4B audiobooks, a format favored for its chapter support and single-file structure. Developed by sandreas and contributed to by a community of users, it aims to abstract away the complexities of directly using FFmpeg and AtomicParsley for this specific task, providing a more user-friendly and specialized interface. Its development has focused on robustness, feature expansion (like advanced tagging and chapter management), and cross-platform compatibility, making it a go-to tool for automating audiobook conversion workflows.