Skip to main content

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

Project description

BPM4B - Professional Multimedia Suite (v9.0.0)

A professional multimedia processing suite for converting MP3 to M4B, M4B to MP3, and generating AI Audiobooks with high-fidelity TTS and automatic chapter support.

Available in two versions:

  • Python (Flask): pip install bpm4b then bpm4b
  • Node.js (Express): npm install -g bpm4b then bpm4b

Installation

Python Version (Original)

pip install bpm4b
bpm4b web

Node.js Version

npm install -g bpm4b
bpm4b web

Or for local development:

git clone https://github.com/jdjchelp-jpg/nodebpm4b.git
cd nodebpm4b
npm install
npm start

Update:

# Update Python version
pip install --upgrade bpm4b

# Update Node.js version
npm update -g bpm4b

Features

๐ŸŽฏ Unified Smart Mode

  • Single toggle switch: Conversion Mode vs Chapter Builder Only
  • Automatic chapter attachment to MKV/M4B output when conversion mode is ON
  • Standalone timestamp generator when mode is OFF

๐Ÿ“ File Conversion Section

  • MP3 to M4B: Convert MP3 files to audiobook format with embedded chapters
  • M4B to MP3: High-fidelity conversion from M4B/M4A containers to MP3 (NEW in v9)
  • Document to Audiobook: Generate high-quality voiceovers from PDF/Text using Kokoro-82M AI (NEW in v9)
  • Drag-and-drop file upload for all tools
  • Real-time progress monitoring with SSE (Server-Sent Events)
  • Visual progress bar and live terminal logging

โฑ Automatic Chapter Builder

  • Always enabled - core functionality
  • Enter chapter title and duration (minutes or seconds toggle)
  • System automatically:
    • Converts input to proper format
    • Accumulates duration to cumulative total
    • Calculates next chapter start timestamp
    • Generates proper HH:MM:SS format
  • No manual math required - all timestamps auto-generate
  • Batch import/export chapter lists
  • Real-time preview updates

โš™ Settings Panel

  • Dark / Light mode toggle
  • Modern toggle switches (not checkboxes)
  • Glassmorphism card design
  • Smooth animations and transitions
  • Responsive layout optimized for desktop

๐Ÿš€ Performance Improvements

  • Faster parsing with optimized algorithms
  • Non-blocking UI with background conversion
  • Proper error handling and validation
  • File size validation before processing
  • Automatic cleanup of temporary files

๐Ÿ“‹ Professional Features

  • Copy-to-clipboard buttons for generated commands
  • Real-time updating preview panel
  • FFmpeg command preview (self-service mode)
  • Export chapters to .txt format
  • Modern, clean, professional SaaS-like interface

Prerequisites

Node.js Version

No additional prerequisites needed! FFmpeg is bundled with the Node.js version, so it works out of the box.

Python Version (Original)

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

Installing FFmpeg (Python Version Only)

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 Python version requires FFmpeg. The Node.js version includes FFmpeg automatically.

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, add chapters using the automatic chapter builder, and click "Convert to M4B"

  • Automatically converts to M4B format (iTunes/Apple Books compatible)
  • Chapters automatically embedded with titles and timestamps
  • Uses FFmpeg for high-quality AAC audio (64kbps - 256kbps)

M4B to MP3: Upload an M4B/M4A file and convert it to a standard MP3

  • High-fidelity conversion using the libmp3lame encoder
  • Perfect for playback on legacy devices or sharing

Audiobook Gen: Upload a PDF or Text document to generate a full audiobook

  • Powered by Kokoro-82M Local TTS engine
  • High-quality, human-like voice synthesis
  • Automatic chapter detection and manifest generation

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}
]

POST /api/convert

Converts MP3 to M4B or M4B to MP3.

Form Data:

  • source_file: The file to convert
  • output_name: Custom filename
  • audio_quality: Bitrate (e.g., '128k', '256k')
  • chapters (optional): JSON array of chapter objects.

POST /api/generate-audiobook

Generates an audiobook from a document.

Form Data:

  • doc_file: The PDF or Text file
  • voice: Selection from available Kokoro voices
  • output_name: Custom filename

GET /api/health

Health check endpoint. Returns JSON with status and FFmpeg availability.

Response: Returns an M4B file as a download.

Project Structure

Python Version

.
โ”œโ”€โ”€ 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

Node.js Version

.
โ”œโ”€โ”€ bin/
โ”‚   โ””โ”€โ”€ bpm4b.js       # CLI entry point
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ core.js        # Core conversion functions
โ”‚   โ””โ”€โ”€ server.js      # Express web server
โ”œโ”€โ”€ templates/
โ”‚   โ””โ”€โ”€ index.ejs      # Frontend template
โ”œโ”€โ”€ api/
โ”‚   โ””โ”€โ”€ index.js       # Vercel serverless function
โ”œโ”€โ”€ examples/          # Usage examples
โ”œโ”€โ”€ test/              # Unit tests
โ”œโ”€โ”€ package.json       # NPM package configuration
โ”œโ”€โ”€ vercel.json        # Vercel configuration
โ”œโ”€โ”€ uploads/           # Temporary uploaded files (created automatically)
โ”œโ”€โ”€ outputs/           # Generated files (created automatically)
โ””โ”€โ”€ README_NODE.md     # Node.js specific documentation

Notes

  • Maximum file size for uploads: 2GB
  • SSE (Server-Sent Events) used for real-time progress updates
  • Kokoro AI engine runs locally (no API keys or external costs)
  • M4B output files can be large (typically 0.96-2GB per hour of audio depending on bitrate)
  • Optimized for high-speed conversion on Windows/macOS/Linuxion:
  • X (Twitter): @jdjchelp

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-9.0.2.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

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

bpm4b-9.0.2-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bpm4b-9.0.2.tar.gz
Algorithm Hash digest
SHA256 8ded88606202a1a0578b72e4dd9309e0d5dfe70972f54fba90401dac4e3e7041
MD5 20df93059b4a586ca3d62bd32fd43383
BLAKE2b-256 8916f2daadff87f8c544612602712fa962f4d0df53cedcc71421abbea3cfbe0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpm4b-9.0.2.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-9.0.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for bpm4b-9.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd84fb1f6a0bf477f419ef1ef86ab6d558059ee0b6e45e769d4f133b2c04af8d
MD5 e0849377d05a775f6c5f5a9d0f7ef077
BLAKE2b-256 53106af024241412c9961f92ece78eb246e28068addce9873bc3abcc59998750

See more details on using hashes here.

Provenance

The following attestation bundles were made for bpm4b-9.0.2-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