Voxbound / Guides / Edit M4B chapters
How to add or edit chapters in an M4B file without re-encoding
You can add, rename or move the chapters of an M4B you already have without re-encoding it: FFmpeg copies the audio untouched and writes an edited chapter list into a new file. In Voxbound, the Chapters tab loads a finished book's chapters and Update tags only writes your edits back, also without re-encoding.
Before you start
The commands need FFmpeg, which includes ffprobe; our MP3 to M4B guide shows how to install it. Run them in Windows PowerShell, in the folder that holds the book, with the file name in place of book.m4b.
Every command here writes a new file and leaves the original as it is, so keep the original until you have played the new one. None of them re-encodes the audio, so its quality and size don't change; the file itself changes slightly, because its index and chapter list are written again. Copy-protected files can't be edited with these commands or with Voxbound.
See the chapters you have
Start by listing what the book holds:
ffprobe -v error -show_chapters -of compact "book.m4b"
Each chapter prints as one line with its start time and end time in seconds, and its title. No lines means the book has no chapters yet. Run the same command on the new file after each change below.
The free way: FFmpeg and a text file
FFmpeg can write a book's tags and chapters to a plain text file in its FFMETADATA format, and read an edited copy back in. Editing the text file is how you rename, move, add or remove chapters.
1. Write the chapters to a text file
ffmpeg -v error -i "book.m4b" -f ffmetadata "chapters.txt"
This is the extraction command in FFmpeg's documentation, with -v error added to keep the output short. The file starts with the line ;FFMETADATA1 and the book's tags, followed by one block for each chapter:
[CHAPTER]
TIMEBASE=1/1000
START=30000
END=60000
title=Middle
TIMEBASE=1/1000 means START and END count milliseconds, so this chapter runs from 30 seconds to 60 seconds. A book with no chapters gets the tags and no blocks. If chapters.txt already exists, FFmpeg asks before replacing it.
2. Edit the text file
Open chapters.txt in Notepad. Leave the lines above the first [CHAPTER] alone: the command in the next step takes the book's tags from the book, so changes there have no effect. Then:
- To rename a chapter, change its
title=line. - To move a chapter, change its
START, and theENDof the chapter before it, so that each chapter ends where the next one starts. - To remove a chapter, delete its whole block and give the chapter before it the removed one's
END. - To split a chapter in two, copy its block, end the first block at the new time (
END) and start the copy there (START), then give the copy a title.
For a book with no chapters, add one block for each chapter at the end of the file. Three chapters of 30 minutes look like this:
[CHAPTER]
TIMEBASE=1/1000
START=0
END=1800000
title=Prologue
[CHAPTER]
TIMEBASE=1/1000
START=1800000
END=3600000
title=Chapter 1
[CHAPTER]
TIMEBASE=1/1000
START=3600000
END=5400000
title=Chapter 2
The last END should be the book's length in milliseconds. This prints the length in seconds. Multiply it by 1000 and drop the decimals, because START and END are whole numbers: 5400.043 becomes 5400043.
ffprobe -v error -show_entries format=duration -of csv=p=0 "book.m4b"
Two details from FFmpeg's description of the format matter when you edit. A title containing =, ;, # or a backslash needs a backslash in front of each of those characters, and a backslash itself is written as two: AC\\DC Live is read as AC\DC Live. And every block needs its TIMEBASE=1/1000 line: the documentation says that without one, START and END are read as nanoseconds, and in our test the chapters' times collapsed towards the start of the book.
Save the file as UTF-8 without a byte order mark. In our tests FFmpeg refused a chapters file that starts with one, with the error Invalid data found when processing input, and wrote nothing; ordinary Windows line endings were fine. In Notepad, choose File, then Save as, and set Encoding to the plain UTF-8 choice, not the one that mentions BOM. UTF-8 keeps accented titles intact.
3. Write the chapters into a copy of the book
ffmpeg -i "book.m4b" -i "chapters.txt" -map 0:a -map 0:v? -map_metadata 0 -map_chapters 1 -c copy -disposition:v attached_pic -movflags +faststart "book-edited.m4b"
What each part does:
-map 0:a -map 0:v?takes the audio and the cover, if there is one, from the book;-map_metadata 0keeps the book's title, author and other tags as they are;-map_chapters 1takes the chapters fromchapters.txt, the second input, instead of the book's own;-c copycopies the audio and cover without re-encoding;-disposition:v attached_pickeeps the picture marked as the cover;-movflags +faststartmoves the file's index to the front.
FFmpeg writes the chapters both as a QuickTime chapter track and as a Nero chapter list, the two formats players read.
4. Check the result
List the new file's chapters with the command from the start, this time on book-edited.m4b. To confirm the audio is the same, print a fingerprint of the audio in each file:
ffmpeg -v error -i "book.m4b" -map 0:a -c copy -f md5 -
Run it once on book.m4b and once on book-edited.m4b. The two MD5= lines are identical when the audio wasn't touched. Then open the new file in your player and skip between a few chapters. Once it is right, put it in place of the original under the original's name.
Rules that keep the chapters working
- FFmpeg writes whatever list you give it and checks nothing, so keep the blocks in time order, each with an
ENDafter itsSTART. A chapter listed out of order breaks the QuickTime chapter track, and our guide to chapters that are out of order or overlap shows what that looks like. - A player that reads only the Nero chapter list shows at most 255 chapters; the QuickTime chapter track holds more, as the same guide explains.
- If Audiobookshelf still shows the old chapters after you replace the file, see Audiobookshelf still shows the old chapters.
The Voxbound way
Voxbound 4.1.14 and later edit a finished book's chapters in a table, without a text file, and write them back without re-encoding. Update tags only isn't part of the free trial; it needs a licence key.
- Drop the M4B onto the Voxbound window. Load from file and Update tags only work only when the list holds one finished book: a single
.m4b,.m4aor.mp3file. The other chapter tools work on any list. - In the Book card, click Import tags to fill in the book's current details from the file. Update tags only writes every box in the card into the file, and removes a tag whose box is empty; its dialog names any that would go.
- Open the Chapters tab and click Load from file. The book's chapters appear in a table with each chapter's start time and length. If the book has none, it says so.
- Click a title to rename a chapter, or a start time to move it. A start time is written as
1:04:30,4:30or in seconds. The toolbar has + Add, Split, Merge ↓, ↑ Move up, ↓ Move down and Delete. If the list has empty, out-of-order or overlapping chapters, a bar says so and Auto-fix repairs them. - Click Update tags only at the bottom of the window. The dialog says how many chapters will replace the book's own, and that the audio is copied as it is. Choose Update this file, or Save a copy… to keep the original.
If the book has no chapters yet, the Chapters tab has other ways to fill the table: + Add and type the times, Import .cue or Import .txt, or Paste chapter list for a list copied from a web page. Find chapters online opens a search for the book's chapter list in your browser, and you copy the list it shows into Paste chapter list; Voxbound sends nothing. Voxbound doesn't find chapters from the audio itself: you supply the times.
Updating a file in place writes a temporary file, checks that it is as long as the original, to within two seconds, and then swaps it in, so a failure leaves the original as it was. Chapters are put in time order before they are written, and the dialog after the update lists anything Voxbound corrected. The audio, and the cover unless you chose a new one, are copied unchanged.
The two ways side by side
| FFmpeg | Voxbound | |
|---|---|---|
| You edit | A text file, in milliseconds | A table: click a title or a start time |
| The audio | Copied, not re-encoded | Copied, not re-encoded |
| Chapters out of order | Written as given; you keep the list in order | Put in order before writing, with a note of what changed |
| The original | Untouched; the result is a new file | Updated in place, or a copy if you choose Save a copy… |
| Cost | Free | Needs a licence key; not part of the free trial |
To see whether a book's chapters are the problem before you edit anything, our guide to M4B chapters not showing covers the common causes, and what an M4B file is covers the file itself.
How to edit audiobook metadata and change the cover art
To edit an audiobook's metadata or change its cover art without re-encoding, write the new title, author, narrator, series or cover into a copy of the file, with the audio copied as it is. Either use FFmpeg, a free M4B metadata editor, or use Voxbound's Update tags only, an audiobook metadata editor that needs a licence key and isn't part of the free trial.
Change the tags with FFmpeg
These commands are for an M4B: an MP3 keeps its series under other tag names (series and series-part), which this page doesn't cover. This one writes the details below into a copy of the book and keeps its audio, chapters and cover. Put your own values between the quotes, and delete the -metadata options for tags you don't want to change.
ffmpeg -i "book.m4b" -map 0:a -map 0:v? -c copy -disposition:v attached_pic -map_metadata 0 -map_chapters 0 -metadata title="The Saga: Book Two" -metadata album="The Saga: Book Two" -metadata artist="Jane Author" -metadata album_artist="Jane Author" -metadata composer="Sam Reader" -metadata show="The Saga" -metadata episode_id="2" -metadata grouping="The Saga #2" -movflags +faststart "book-tagged.m4b"
The options other than -metadata are the ones step 3 above explains. FFmpeg's documentation says -metadata sets one tag, overrides the same tag copied by -map_metadata, and deletes a tag when its value is empty: -metadata composer= removes the narrator. The tag names are the ones Voxbound writes into an M4B (the table in Formats, chapters and tags lists them all):
- the title is written to
titleandalbum, and the author toartistandalbum_artist; - the narrator is
composer; - the series is
show, its number isepisode_id, andgroupingholds both, asThe Saga #2; - the year is
date, the genre isgenre, and the description isdescriptionandcomment.
Unlike the chapters text file, -metadata needs no backslashes: in our test a title with =, ; and # in it was stored as typed. In Windows PowerShell, values in double quotes can hold accents, apostrophes, =, ; and #. A value with a double quote or a dollar sign goes in single quotes instead, with an apostrophe written twice and a double quote written as \": 'The \"Big\" Book, O''Brien' is stored as The "Big" Book, O'Brien. Inside double quotes PowerShell would read $ as the start of a variable name.
Check the new file's tags with this, then run the fingerprint command from step 4 on both files and the chapters command from the start on the new one:
ffprobe -v error -show_entries format_tags -of default=noprint_wrappers=1 "book-tagged.m4b"
For a series alone, the Audiobookshelf settings guide has a shorter command.
Change the cover art with FFmpeg
To replace the cover, add the picture as a second input and take the book's picture from it instead. A JPEG is the safe choice: it is the format Voxbound stores every cover in. The command copies the picture as it is and keeps the audio, chapters and tags.
ffmpeg -i "book.m4b" -i "cover.jpg" -map 0:a -map 1:v -c copy -disposition:v attached_pic -map_metadata 0 -map_chapters 0 -movflags +faststart "book-cover.m4b"
-map 1:v takes the picture from cover.jpg, the second input, and leaves the old cover behind. This prints the codec, size and cover flag of the picture in the new file:
ffprobe -v error -select_streams v -show_entries stream=codec_name,width,height:stream_disposition=attached_pic -of default=noprint_wrappers=1 "book-cover.m4b"
The size should be that of your image, and DISPOSITION:attached_pic=1 means it is marked as the cover.
Change the details and cover in Voxbound
- Add the book and click Import tags, as in steps 1 and 2 of the Voxbound way.
- In the Book card, change Title, Author, Narrator, Series and Series #. Year, Genre and Description are there too. An M4B or M4A has no place for Subtitle, Publisher and Language, so they aren't kept (an MP3 keeps them).
- To change the cover, click Choose… in the Cover card and pick a JPG, PNG or BMP image, or use Look up in the Book card, which can find a cover online. Clear drops your choice and the file keeps its own cover: Voxbound can replace a cover but not remove one.
- Leave the Chapters tab alone to keep the chapters. The dialog then says Chapters: the file keeps its own.
- Click Update tags only. The dialog lists what happens to the cover and the chapters, and names any tag that will be removed because its box is empty. Choose Save a copy… or Update this file.
Voxbound writes the tags listed above from the Book card's boxes, and keeps standard tags such as the copyright. It adds the new cover as a JPEG whatever image you chose. An .m4a is marked as an audiobook again, and an MP3 gets ID3v2.3 tags.
What to watch for
- Copy-protected files can't be edited with either method, as Before you start says.
- Update this file replaces the book. Choose Save a copy… to keep the original until the new file plays, as you do with the FFmpeg commands, which always write a new file.
- If the book is in Audiobookshelf, a book it already knows can keep its old details after a scan, and an image in the book's folder is used before the embedded cover. The Audiobookshelf section of the settings guide covers both.
Questions
Short answers about editing M4B chapters.
How do I add chapters to an M4B?
Write the chapters to a text file with FFmpeg, add a block for each chapter with TIMEBASE=1/1000, its title, and its start and end in milliseconds, and write the list into a copy with -map_chapters and -c copy. In Voxbound, add them in the Chapters tab and click Update tags only.
Is there an M4B chapter editor?
Voxbound's Chapters tab is one: it loads a finished book's chapters, and you rename, move, add or delete them in a table. The free way is FFmpeg with an edited text file.
How do I rename the chapters in an M4B?
Change the title= line of each chapter in the text file and write it back with the command on this page. In Voxbound, load the chapters, click a title to change it, and click Update tags only.
Can I edit M4B chapters without re-encoding?
Yes. FFmpeg with -c copy and Voxbound's Update tags only both copy the audio as it is. Comparing an MD5 fingerprint of the audio before and after shows it is unchanged.
How do I add chapters to an M4B that has none?
Export the tags to a text file, add a chapter block at the end of the file for each chapter, and write it into a copy. In Voxbound, add the times in the Chapters tab or paste a chapter list, then click Update tags only. Neither finds chapters from the audio: you supply the times.
Why don't my new chapters show in Audiobookshelf?
By default, Audiobookshelf's own metadata file takes priority over the tags in the audio file, and it uses the chapters saved there when there are any. Correct them in its chapter editor, or change the library's metadata order and scan again.
Fix chapters without a text file
Voxbound loads a finished book's chapters, lets you edit them in a table and writes them back without re-encoding the audio.
Buy Voxbound Try one book free