audiobook-converter
v1.0.0
Published
Convert folders of audio chapters into Apple Books-compatible M4B audiobooks
Maintainers
Readme
Audiobook Converter
Turn a folder of audio chapters into a single .m4b audiobook for Apple Books.
The converter keeps chapters in the correct order, adds chapter markers and book details, and embeds a cover image when one is available. Your original audio files are never changed or deleted.
What it can do
- Combine many chapter files into one M4B audiobook
- Create chapter markers using the original filenames
- Sort numbered files correctly (
2comes before10) - Add a title, author, audiobook genre, and cover image
- Show progress while the audiobook is being created
- Work with AAC, AIFF (
.aifand.aiff), FLAC, M4A, MKA, MP3, OGG, OPUS, WAV, and WMA files - Mix supported audio formats in the same folder
- Preserve stereo audio
- Refuse to overwrite an existing audiobook
Before you start
You need:
- macOS
- Node.js 18 or newer
- FFmpeg
The easiest way to install everything is with Homebrew:
brew install node ffmpegInstallation
Install the converter from npm:
npm install --global audiobook-converterYou can now use audiobook-convert from any folder in Terminal.
To check that it is installed:
audiobook-convert --versionQuick start
1. Prepare the audiobook folder
Put all chapter files directly inside one folder. Their filenames determine their order and chapter titles.
My Audiobook/
├── 01 - Introduction.opus
├── 02 - The First Day.opus
├── 03 - A New Discovery.mp3
└── cover.jpgNumbered files are sorted naturally, so 1, 2, and 10 appear in that
order. A leading number and separator are removed from the chapter title:
01 - Introduction.opus → Introduction
02. The First Day.mp3 → The First Day
03_A New Discovery.wav → A New Discovery2. Run the converter
Pass the folder to the command:
audiobook-convert "/Users/me/Downloads/My Audiobook"Quotes are recommended when a path contains spaces.
3. Open the result
The finished M4B is created next to the input folder:
Downloads/
├── My Audiobook/
└── My Audiobook.m4bDrag the .m4b file into Apple Books or use File → Import in the Books app.
Add book details
Use --title and --author to set the information shown in Apple Books:
audiobook-convert \
"./Harry Potter 1" \
--title "Harry Potter and the Philosopher's Stone" \
--author "J. K. Rowling"If no title is provided, the input folder name is used. If no author is
provided, the audiobook uses Unknown Author.
Add a cover
When no cover is specified, the converter automatically looks inside the audiobook folder for these filenames:
cover.jpg
cover.jpeg
cover.png
folder.jpg
folder.pngYou can choose another image with --cover:
audiobook-convert "./My Audiobook" --cover "./artwork.png"JPG and PNG images are supported. The image is embedded inside the finished M4B, so the separate cover file is not needed afterward.
Choose the output file
Use --output or -o to choose where the audiobook is saved:
audiobook-convert \
"./My Audiobook" \
--output "/Users/me/Desktop/My Audiobook.m4b"The .m4b extension is added automatically when omitted. Existing files are
never replaced; choose a different output path or move the old file first.
Choose audio quality
The default AAC bitrate is 96k, which is a good balance for spoken audio.
Use --bitrate if you prefer a different value:
audiobook-convert "./My Audiobook" --bitrate 128kA higher bitrate can improve quality but creates a larger file.
Full example
audiobook-convert \
"/Users/me/Downloads/Upgrade" \
--title "Upgrade" \
--author "Blake Crouch" \
--cover "/Users/me/Downloads/Upgrade/cover.jpg" \
--bitrate 128k \
--output "/Users/me/Downloads/Blake Crouch - Upgrade.m4b"Options
| Option | Purpose |
| --- | --- |
| --title "Book Title" | Set the audiobook title |
| --author "Author Name" | Set the author |
| --cover path/to/image.jpg | Choose a JPG or PNG cover |
| --output path/to/book.m4b | Choose the output file |
| -o path/to/book.m4b | Short form of --output |
| --bitrate 128k | Choose the AAC bitrate; default is 96k |
| --verbose or -v | Show more details when diagnosing a problem |
| --help or -h | Show command help |
| --version | Show the installed version |
Troubleshooting
ffmpeg or ffprobe is missing
Install FFmpeg and try again:
brew install ffmpegNo supported audio files were found
Make sure the chapter files:
- use one of the supported formats listed above
- are directly inside the selected folder, not inside subfolders
- have normal audio file extensions such as
.opus,.mp3, or.m4a
The output file already exists
The converter will not overwrite an audiobook. Move or rename the existing
file, or choose another path with --output.
An audio file or cover cannot be read
The file may be damaged or use an unsupported variation. Run the command again
with --verbose to see which file caused the problem:
audiobook-convert "./My Audiobook" --verboseApple Books shows old information
Apple Books may remember details from an older import. Remove the old copy from Books, then import the new M4B again.
Uninstall
npm uninstall --global audiobook-converterDevelopment
To work on the project locally, clone the repository and install its dependencies with pnpm:
git clone https://github.com/birosrichard/audiobook-converter.git
cd audiobook-converter
pnpm install
pnpm test
pnpm link --globalLicense
MIT
