A cross-platform tool designed to convert Libby audiobook downloads into M4B format with proper chapter markers. This tool automatically processes audio files and metadata to create professionally formatted M4B audiobooks that work great with audiobook players like Apple Books, Plex, and more.
Perfect for processing audiobooks downloaded from Libby (Overdrive) into a format compatible with most audiobook players while preserving chapter information.
- Install FFmpeg (see Prerequisites section)
- Make the script executable (one-time setup):
chmod +x convert_audiobook.sh
- Run the script and drag-and-drop one or more audiobook folders after the command:
./convert_audiobook.sh <drag folders here> # Process multiple folders
./convert_audiobook.sh --output-dir ~/Books <folders> # Specify output directory
This tool is designed to work with audiobook files downloaded from Libby/Overdrive using the LibreGrab userscript, available at https://greasyfork.org/en/scripts/498782-libregrab.
Files downloaded using LibreGrab will already be in the correct format with proper metadata structure, which ensures optimal compatibility with this script. This tool is specifically optimized for processing audiobooks obtained through LibreGrab.
- Cross-platform support (Windows PowerShell and Unix/Linux shell)
- Specifically designed for Libby audiobook downloads
- Converts MP3 files to M4B format
- Automatically creates chapter markers
- Preserves audio quality
- Maintains original audio bitrate
- Supports metadata inclusion
- Multiple folder support (process multiple audiobooks in one command)
- Easy to use with a simple command
- Automatically moves completed audiobooks to ~/totag directory
- Handles file/directory names with spaces and special characters
- Progress tracking during conversion
- FFmpeg is required for audio conversion:
- macOS:
brew install ffmpeg
- Linux:
sudo apt-get install ffmpeg
- Windows: Download from https://ffmpeg.org/download.html
- Create the ~/totag directory for completed audiobooks:
mkdir -p ~/totag
- Clone or download this repository
- Open Terminal
- Navigate to the downloaded folder
- Make the script executable:
chmod +x convert_audiobook.sh
- Clone or download this repository
- Ensure PowerShell execution policy allows local scripts:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
- No additional setup required - use convert_audiobook.ps1
- Keep your Libby downloaded audiobook files in their original structure:
- MP3 files in the root directory
- A
metadata
folder containingmetadata.json
- Run the conversion script:
Unix/Linux/macOS:
./convert_audiobook.sh "path/to/audiobook folder"
Windows:
.\convert_audiobook.ps1 -Path "path\to\audiobook folder"
You can convert multiple audiobooks sequentially by dragging multiple folders:
./convert_audiobook.sh <drag folder 1> <drag folder 2> <drag folder 3>
You can also specify a custom output directory for all converted books:
./convert_audiobook.sh --output-dir ~/MyAudiobooks <folder 1> <folder 2> <folder 3>
The script will:
- Process each audiobook folder one at a time
- Create chapter markers using information from metadata.json
- Combine MP3 files into a single M4B audiobook for each folder
- Name each output file based on its folder name
- Save all M4B files to the specified output directory (if --output-dir is used)
Check the example
directory for a complete working example.
your-audiobook-folder/
├── *.mp3 # Your audiobook MP3 files
└── metadata/
└── metadata.json # Chapter information file
./convert_audiobook.sh "~/Downloads/My Audiobook"
./convert_audiobook.sh "~/Downloads/Book1" "~/Downloads/Book2" "~/Downloads/Book3"
This repository includes an example directory that demonstrates proper setup:
- Sample audio files in the correct format
- A properly formatted metadata.json
- An example cover image
- A README explaining usage
Create a metadata.json
file in the metadata folder:
{
"chapters": [
{
"title": "Introduction",
"duration": 1234
},
{
"title": "Chapter 1",
"duration": 5678
}
]
}
Notes:
duration
: Length of chapter in secondstitle
: Chapter title as it will appear in the audiobook
The script will create an M4B file with:
- Proper chapter markers
- Maintains original audio quality and bitrate
- Embedded cover art (if provided)
- The same name as your book folder
- LibbyRip/LibreGrab (https://github.com/HeronErin/LibbyRip) - A userscript that enables downloading audiobooks from Libby/Overdrive in a format compatible with this tool. Also available on Greasyfork.
If you encounter any issues:
- Make sure FFmpeg is installed and accessible
- Check that your files follow the correct structure
- Verify your metadata.json format
- Check the terminal output for any error messages