Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weak-head/m4b-maker
A set of bash scripts to convert audio files into M4B audiobooks with chapter markers and customizable bitrate.
https://github.com/weak-head/m4b-maker
audiobook bash m4b m4b-book m4b-tool shell-script
Last synced: 14 days ago
JSON representation
A set of bash scripts to convert audio files into M4B audiobooks with chapter markers and customizable bitrate.
- Host: GitHub
- URL: https://github.com/weak-head/m4b-maker
- Owner: weak-head
- License: mit
- Created: 2024-11-12T21:31:37.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-12-31T18:44:21.000Z (about 1 month ago)
- Last Synced: 2024-12-31T19:30:26.201Z (about 1 month ago)
- Topics: audiobook, bash, m4b, m4b-book, m4b-tool, shell-script
- Language: Shell
- Homepage:
- Size: 61.5 KB
- Stars: 33
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# M4B Audiobook MakerA set of bash scripts to convert audio files into M4B audiobooks with chapter markers, customizable bitrate, book metadata and embedded cover art.
## Table of Contents
- [Overview](#overview)
- [Getting Started](#getting-started)
- [m4bify](#m4bify)
- [m4bulk](#m4bulk)
- [Usage Examples](#usage-examples)## Overview
M4B Audiobook Maker is a set of bash scripts that simplify converting audio files into the M4B audiobook format. It includes `m4bify` for single conversions and `m4bulk` for batch processing.
**Single Audiobook Conversion (`m4bify`)**
Combines audio files into a single M4B audiobook with chapter markers, ensuring correct playback order by processing files alphabetically. Chapters are automatically created based on metadata, filenames, or top-level subdirectories. You can customize the audio quality, and if an image file or embedded art is available, it will be added as the book cover. Additionally, directory names that follow supported patterns are parsed to extract metadata such as the author, title, and year.
**Batch Audiobook Conversion (`m4bulk`)**
Scan a root directory for audiobook folders and convert them to M4B files in parallel. Pass custom options, such as bitrate and chapter settings, to apply them to all audiobooks. `m4bulk` leverages multiple worker threads for simultaneous processing, speeding up batch conversions.
## Getting Started
Ensure the following dependencies are installed: [ffmpeg](https://ffmpeg.org) and [mp4v2](https://mp4v2.org/).
```bash
# For RPM-based systems (Fedora, RHEL, CentOS)
sudo dnf install ffmpeg libmp4v2# For Debian-based systems (Ubuntu, Debian)
sudo apt install ffmpeg
```To install the scripts, run:
```bash
make install
```This installs the scripts to `/usr/local/sbin/`.
## m4bify
`m4bify` creates M4B audiobook by processing files in the specified directory, sorting them alphabetically to ensure the correct playback order. Chapters can be organized either as file-based, where each audio file becomes its own chapter named using metadata or filenames, or directory-based, where each top-level subdirectory is treated as a chapter, combining all its audio files, including those in nested folders, into one.
Other features include:
- Configurable audio bitrate, with high-quality AAC VBR as the default.
- Metadata extraction from directory names that follow supported patterns.
- Automatic cover art inclusion from image files or embedded artwork.
- Comprehensive logs with chapter metadata.**Syntax**
```bash
m4bify [--help] [-d | --chapters-from-dirs] [-b | --bitrate ]
```**Options**
- `-d`, `--chapters-from-dirs`: Treats each top-level subdirectory as a chapter.
- `-b `, `--bitrate `: Sets the audio encoding bitrate (e.g. "128k", default: VBR Very High).
- `--help`: Displays usage instructions and exits.**Arguments**
- `` (required): Path to the directory containing audiobook files.
**Directory Patterns**
| Pattern | Example |
|---|---|
| ` - ()` | J.K. Rowling - Harry Potter and the Philosopher's Stone (1997) |
| ` - ` | Agatha Christie - Murder on the Orient Express |
| ` ()` | To Kill a Mockingbird (1960) |Both hyphen (`-`) and underscore (`_`) are supported as separators. Additionally, square brackets (`[]`) can be used as an alternative to parentheses (`()`) for enclosing year information.
## m4bulk
`m4bulk` automates batch conversion of audiobook folders to M4B format using `m4bify`. It scans a root directory for audiobook folders and processes them in parallel.
Key features:
- Distributes tasks across multiple workers.
- Automatically detects audiobook directories in the root folder.
- Allows customization of `m4bify` options, such as bitrate and chapter generation.
- Generates and saves logs for each audiobook conversion in the source folder.**Syntax**
```bash
m4bulk [--help] [--workers ] [m4bify-options]
```**Options**
- `--workers `: Number of worker threads (default: 50% of CPU cores).
- `--help`: Displays usage instructions and exits.**Arguments**
- `[m4bify-options]` (optional): Optional arguments passed directly to `m4bify` (e.g. `-b `).
- `` (required): Directory containing subdirectories of audiobooks to convert.## Usage Examples
**Metadata Extracted from Directory Name**
Combine all audio files in `/home/user/audiobooks/Author Name - Book Title (1993)/` into a single M4B audiobook. Chapters are automatically generated based on file metadata or filenames. Author, title and year are extracted from the directory name:
```bash
m4bify "/home/user/audiobooks/Author Name - Book Title (1993)"
```**Subdirectory Chapters with Custom Bitrate**
Combine all top-level subdirectories in `/home/user/audiobooks/book/` into a single audiobook, with each subdirectory treated as a separate chapter. Files are processed recursively in alphabetical order, with audio encoded at 96 kbps:
```bash
m4bify --chapters-from-dirs --bitrate 96k /home/user/audiobooks/book
```**Bulk Conversion with Default Settings**
Convert all subdirectories in `/home/user/audiobooks/` to M4B format using default settings. The process utilizes 50% of available CPU cores:
```bash
m4bulk /home/user/audiobooks
```**Bulk Conversion with Custom Threads and Bitrate**
Convert audiobook directories in `/home/user/audiobooks/` with 4 worker threads. Each subdirectory is treated as a chapter, and audio is encoded at 128 kbps:
```bash
m4bulk --workers 4 -d -b 128k /home/user/audiobooks
```## Contributing
Contributions, bug reports, and feature requests are welcome! Feel free to open an issue or submit a pull request.
## License
This project is licensed under the MIT License. See the LICENSE file for details.
## Acknowledgments
Thanks to the creators of [ffmpeg](https://ffmpeg.org) and [mp4v2](https://mp4v2.org/) for their excellent tools that make this project possible.