2

I have m4a, m4b, and mp4 versions of an audiobook (the video mp4 version just has the book's cover for the entire duration). I'm trying to add chapter metadata to the audiobook using ffmpeg. I've tried the following, but Apple Books fails to recognise the chapters with all of these methods: ffmpeg -i input.m4a -i chapters.txt -map_metadata 1 -codec copy output.m4a where chapters.txt resembles this:

[CHAPTER]
TIMEBASE=1/1000
START=1
END=448000
title=Chapter 1

[CHAPTER]
TIMEBASE=1/1000
START=448001
END= 3883999
title=Chapter 2

[CHAPTER]
TIMEBASE=1/1000
START=3884000
END=4418000
title= Chapter 3

I've also tried splitting it into many m4a files and then combining them into a single m4b file, still to no avail using ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.m4b where mylist.txt contains all of the split files.

I want the final output to be an M4B file. How do I add chapter information, while outputting the final file in M4B format?

2
  • Do you have a file where Apple Books recognizes the chapters? If yes, analyzing this file to find out what format Apple Books needs may help. Commented Jun 14, 2021 at 15:11
  • @dirkt I do not. This is my first time using Apple Books. Perhaps there's another audiobook reader that's less annoying to work with? Commented Jun 15, 2021 at 1:22

1 Answer 1

4

You should write

ffmpeg -i input.m4a -i chapters.txt -map 0 -map_metadata 1 -c copy output.m4b

Operand explanation:

  • -i input.m4a - first input file (index = 0)
  • -i chapters.txt - second input file (index = 1)
  • -map 0 - map all streams from first input file to output file
  • -map_metadata 1 - map metadata from second input file to output file
  • -c copy - do not re-encode data
  • output.m4b - output file

chapters.txt might also contain other metadata, for example:

;FFMETADATA1
title=Book title
artist=Author name

[CHAPTER]
TIMEBASE=1/1000
START=0
END=538300
title=Intro

[CHAPTER]
TIMEBASE=1/1000
START=538300
END=2460687
title=Chapter 1

[CHAPTER]
TIMEBASE=1/1000
START=2460687
END=3541787
title=Chapter 2
1
  • 1
    Thank you! But as far as I see the answer is self-explanatory. But I'll add explanation. Commented Jan 3, 2024 at 15:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.