Skip to main content

MP3 to M4B Audiobook Converter - Convert MP3 files to M4B format with chapter support

Project description

MP3 to M4B Audiobook Converter (bpm4b)

A Flask-based web application for converting MP3 files to M4B audiobook format with chapter support.

Install and run with: pip install bpm4b then bpm4b

Features

MP3 to M4B Converter

  • Upload MP3 files
  • Add custom chapter markers with titles and timestamps
  • Automatically converts to M4B format (iTunes/Apple Books compatible)
  • Uses FFmpeg for high-quality AAC audio (64kbps)
  • Simple web interface

Prerequisites

  • Python 3.8+
  • FFmpeg (required for MP3 to M4B conversion)

Installing FFmpeg

Windows:

  1. Go to https://www.gyan.dev/ffmpeg/builds/ (recommended Windows builds)
  2. Download "ffmpeg-git-full.7z" or "ffmpeg-release-full.7z"
  3. Extract the archive using 7-Zip or similar
  4. Open the extracted folder, navigate to the bin folder
  5. Copy the path to the bin folder (contains ffmpeg.exe)
  6. Add to PATH:
    • Press Win + X, select "System"
    • Click "Advanced system settings"
    • Click "Environment Variables"
    • Under "System variables", find and select "Path", click "Edit"
    • Click "New" and paste the path to the bin folder
    • Click OK on all windows
  7. Open a new command prompt and verify: ffmpeg -version

macOS:

brew install ffmpeg

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install ffmpeg

Note: The MP3 to M4B conversion requires FFmpeg. Without it, the converter will not work.

Usage

Web Interface

Start the web server and open your browser to http://localhost:5000:

# Start the server
bpm4b web

# Or with custom options
bpm4b web --port 8080
bpm4b web --host 127.0.0.1 --debug

The web interface allows you to:

  • Upload MP3 files through a simple form
  • Add custom chapter markers with titles and timestamps
  • Download the converted M4B audiobook

Command Line (No Web Interface)

Convert MP3 to M4B directly from the terminal:

# Basic conversion
bpm4b convert input.mp3 output.m4b

# With chapter markers
bpm4b convert input.mp3 output.m4b --chapter "Introduction" 0
bpm4b convert input.mp3 output.m4b --chapter "Chapter 1" 3600 --chapter "Chapter 2" 7200

# Multiple chapters
bpm4b convert book.mp3 book.m4b \\
  --chapter "Prologue" 0 \\
  --chapter "Chapter 1" 300 \\
  --chapter "Chapter 2" 1800

# Multiple chapters with MM:SS format
bpm4b convert book.mp3 book.m4b \\
 --chapter "Prologue" "0:00" \\
 --chapter "Chapter 1" "5:00" \\
 --chapter "Chapter 2" "30:00"

# Mixed formats (seconds and MM:SS)
bpm4b convert book.mp3 book.m4b \\
 --chapter "Intro" 0 \\
 --chapter "Chapter 1" "6:30" \\
 --chapter "Chapter 2" 3600

Chapter start times accept:

  • Seconds as integer (e.g., 390)
  • Minutes:seconds format (e.g., "6:30" or "6:30.5" for fractional seconds)

Using Python Module

Alternatively, you can run it as a Python module:

python -m bpm4b.cli web --port 5000
python -m bpm4b.cli convert input.mp3 output.m4b

Using the CLI (Package Installation)

After installing with pip install -e ., use the bpm4b command:

# Start web interface
bpm4b web

# Web interface with options
bpm4b web --port 8080
bpm4b web --host 127.0.0.1 --debug

# Convert MP3 to M4B directly
bpm4b convert input.mp3 output.m4b
bpm4b convert input.mp3 output.m4b --chapter "Chapter 1" 0

# Show help
bpm4b --help
bpm4b web --help
bpm4b convert --help

Using Python Module

Alternatively, you can run it as a Python module:

python -m bpm4b.cli web --port 5000
python -m bpm4b.cli convert input.mp3 output.m4b

Using the Traditional Method

If you installed dependencies only (without the package):

python app.py

Then open your browser and navigate to:

http://localhost:5000

Using the Tool

Once the server is running:

MP3 to M4B: Upload an MP3 file, optionally add chapter markers, and click "Convert to M4B"

  • Automatically converts to M4B format (iTunes/Apple Books compatible)
  • Add custom chapter titles and timestamps
  • Uses FFmpeg for high-quality AAC audio (64kbps)

API Endpoints

POST /api/mp3-to-m4b

Converts an MP3 file to M4B with optional chapters.

Form Data:

  • mp3_file: The MP3 file to convert
  • chapters (optional): JSON array of chapter objects. start_time accepts seconds (number) or MM:SS format (string):
[
  {"title": "Chapter 1", "start_time": 0},
  {"title": "Chapter 2", "start_time": "6:30"},
  {"title": "Chapter 3", "start_time": 3600}
]

Response: Returns an M4B file as a download.

Project Structure

.
├── bpm4b/              # Main package directory
│   ├── __init__.py    # Package initialization
│   ├── app.py         # Flask application (for local development)
│   ├── cli.py         # Command-line interface entry point
│   ├── core.py        # Shared core functions
│   ├── api/
│   │   ├── __init__.py
│   │   └── index.py   # Vercel serverless function
│   └── templates/
│       └── index.html # Frontend interface
├── setup.py           # Package installation configuration
├── vercel.json        # Vercel configuration
├── requirements.txt   # Python dependencies
├── uploads/           # Temporary uploaded files (created automatically)
├── outputs/           # Generated files (created automatically)
└── README.md          # This file

Notes

  • Maximum file size for uploads: 100MB
  • Temporary files are cleaned up automatically
  • M4B output files can be large (typically 0.96-2GB per hour of audio depending on bitrate)
  • The default audio bitrate is 64kbps AAC, which provides good quality for speech

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bpm4b-2.0.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bpm4b-2.0.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file bpm4b-2.0.0.tar.gz.

File metadata

  • Download URL: bpm4b-2.0.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bpm4b-2.0.0.tar.gz
Algorithm Hash digest
SHA256 abd3b627f94bbe345b82438b17a7a146f94951f0aa79e9eb579e0a6c9c2c61a6
MD5 8dfee00e0f1ca9f819810bd3444e557f
BLAKE2b-256 d7542b3e93150b16076f2456b8cc5e6267cfe85273255f965711792934cbb895

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpm4b-2.0.0.tar.gz:

Publisher: publish.yml on jdjchelp-jpg/bpm4b

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bpm4b-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: bpm4b-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bpm4b-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86da42fba05d11f7bfd45c724e34f3387226b2001d0d97c61c2139846af520da
MD5 5d83d42f809f9867bcc24e7ce588f5ac
BLAKE2b-256 07efd7aec05fc0bff70487b21249e13d8b35af25267ab5480118eff1e257f89c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpm4b-2.0.0-py3-none-any.whl:

Publisher: publish.yml on jdjchelp-jpg/bpm4b

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page