Build and merge M4B audiobooks on Linux from multiple audio files or multi-part M4B sets, with chapter generation, metadata normalization, UTF-8/Russian encoding handling, and validation.
Build a single player-friendly M4B from many audio parts or merge existing M4B parts while preserving metadata, normalizing text to UTF-8, and generating chapters. Keep details in references/guide.md and use the helper script for repeatable inputs.
cover.jpg or same.files.txt and meta.txt.files.txt and follow the reference for chapter merging.-threads) to speed up transcoding.timeout_ms) to avoid re-runs.-map 0:a:0 -vn) to avoid accidental video streams.-c copy only when M4B parts share compatible codecs.albumArtist, performer/narrator for artist) and format person names as Last First. If cover art found, embed it in the final M4B.mediainfo, mp4info, and a target player.Run:
python3 scripts/build_m4b_inputs.py --root . --recursive --chapter-mode dir --files-out files.txt --meta-out meta.txt --ffmpeg-out ffmpeg.sh --output-m4b book.m4b
Use this to create:
files.txt for ffmpeg concat inputmeta.txt for ffmpeg chapter metadataffmpeg.sh with a ready-to-run ffmpeg command line (use --no-ffmpeg-out to skip)atomicparsley.sh with a ready-to-run metadata command (use --no-atomicparsley-out to skip)To generate a safe output filename like Author - Title.m4b, supply --output-author and --output-title (invalid filesystem characters are replaced). The script reorders author names to Last First by default when building the filename (use --name-order keep to preserve input). If omitted and --output-m4b is left at book.m4b, the script derives author/title from the first input's tags and falls back to the folder name. If --output-m4b lacks the extension, .m4b is appended.
python3 scripts/build_m4b_inputs.py --root . --chapter-mode file --files-out files.txt --meta-out meta.txt --output-author "Author" --output-title "Title"
Use --chapter-mode file for per-file chapters, or --chapter-mode none to generate only files.txt. For file chapters, the script prefers embedded track titles when present and falls back to filenames.
Use --chapter-mode file only when file boundaries match real chapters; otherwise prefer dir or a curated chapter list.
For multi-part M4B sets, propose a merge order before any concat work:
python3 scripts/propose_m4b_order.py --root . --files-out files.txt
Use the proposed order and metadata/cover suggestions to build an action plan and ask the user to confirm before merging.
Extract and embed cover art (sidecar image or embedded metadata):
python3 scripts/cover_art.py --root . --recursive --output cover.jpg --embed book.m4b
Use references/guide.md for detailed commands, chapter formats, and scenario-specific procedures.