npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

audiobook-converter

v1.0.0

Published

Convert folders of audio chapters into Apple Books-compatible M4B audiobooks

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 (2 comes before 10)
  • Add a title, author, audiobook genre, and cover image
  • Show progress while the audiobook is being created
  • Work with AAC, AIFF (.aif and .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:

The easiest way to install everything is with Homebrew:

brew install node ffmpeg

Installation

Install the converter from npm:

npm install --global audiobook-converter

You can now use audiobook-convert from any folder in Terminal.

To check that it is installed:

audiobook-convert --version

Quick 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.jpg

Numbered 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 Discovery

2. 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.m4b

Drag 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.png

You 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 128k

A 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 ffmpeg

No 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" --verbose

Apple 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-converter

Development

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 --global

License

MIT