https://github.com/ewilan-riviere/m4b-extractor
Rust CLI tool to extract chapters, metadata and cover for M4B Audiobook.
https://github.com/ewilan-riviere/m4b-extractor
audiobook chapters cli extract m4b metadata rust
Last synced: 10 days ago
JSON representation
Rust CLI tool to extract chapters, metadata and cover for M4B Audiobook.
- Host: GitHub
- URL: https://github.com/ewilan-riviere/m4b-extractor
- Owner: ewilan-riviere
- License: mit
- Created: 2025-07-06T05:51:08.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-07T05:19:42.000Z (12 months ago)
- Last Synced: 2025-09-22T17:52:36.826Z (9 months ago)
- Topics: audiobook, chapters, cli, extract, m4b, metadata, rust
- Language: Rust
- Homepage: https://crates.io/crates/m4b-extractor
- Size: 6.72 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# m4b-extractor
[![rust][rust-version-src]][rust-version-href]
[![tests][tests-src]][tests-href]
[Rust](https://www.rust-lang.org/) CLI tool to extract chapters, metadata and cover for M4B Audiobook. Based on idea of [Hasan Arous](https://unix.stackexchange.com/questions/499179/using-ffmpeg-to-split-an-audible-audio-book-into-chapters).
Available on [crates.io](https://crates.io/crates/m4b-extractor).
## Requirements
- [Rust](https://www.rust-lang.org/)
- [FFmpeg](https://ffmpeg.org/) installed and available in your `PATH`
## Installation
You can install `m4b-extractor` with [Cargo](https://doc.rust-lang.org/cargo/).
```bash
cargo install m4b-extractor
```
## Usage
You have to pass the path to the `.m4b` file you want to extract chapters from.
```bash
m4b-extractor /path/to/input.m4b
```
You will get a directory named `_chapters` containing:
- Each chapter as a separate `.mp3` file.
- A `metadata.json` file with the metadata of the book.
- A `tags.yaml` file with the tags of the book.
- A `folder.jpg` file with the cover of the book.
```plain
1_Chapter 01.mp3
2_Chapter 02.mp3
3_Chapter 03.mp3
# ...
folder.jpg
metadata.json
tags.yaml
```
### Options
```bash
m4b-extractor --help
```
- `-o`, `--output `: Specify the output directory for extracted chapters (default: `_chapters`).
- `-k`, `--keep`: Keep the original `.m4b` files without converting them to `.mp3`.
- `-q`, `--quality `: Specify the conversion quality (1=best, 9=worst) for `.mp3` files (default: `2`).
- `-s`, `--sanitize`: Sanitize filenames by replacing invalid characters with underscores (default: `false`).
- `-h`, `--help`: Print help information.
- `-V`, `--version`: Print the version of the tool.
## Test and publish
Build and test the package:
```bash
# debug build
cargo build
# release build
cargo build --release
cargo test
```
Test publishing:
```bash
cargo publish --dry-run
```
Publish the package to [crates.io](https://crates.io):
```bash
cargo publish
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
[rust-version-src]: https://img.shields.io/badge/Rust-v1.88.0-000000?colorA=18181B&logo=Rust&logoColor=ffffff
[rust-version-href]: https://www.rust-lang.org/
[tests-src]: https://img.shields.io/github/actions/workflow/status/ewilan-riviere/m4b-extractor/run-tests.yml?branch=main&label=tests&style=flat&colorA=18181B
[tests-href]: https://github.com/ewilan-riviere/m4b-extractor/actions