[Bug]: Chapters are wrong when a book consists of multiple .m4b files #544

Closed
opened 2026-04-24 23:12:33 +02:00 by adam · 3 comments
Owner

Originally created by @abstrakct on GitHub (Jul 24, 2022).

Describe the issue

I have some audiobooks that consists of two .m4b files. Each file contains many chapters. Audiobookshelf detects and scans them correctly, but in the chapter list for the book (in audiobookshelf) the first chapter of file 2 is missing. When playing the book in audiobookshelf, all chapters from file 1 are correct, but the first chapter of file 2 has the name of the second chapter in file 2.

Screenshots probably explain it better:

File 2 metadata:
2022-07-24-13-10-01

But in audiobookshelf:
2022-07-24-13-11-24

As you can see, "Chapter 30 - Beyond the Oak" is missing in audiobookshelf -- but if I play the book and skip to what audiobookshelf thinks is "Chapter 31 - Assurances" it starts playing at the beginning of file 2, at "Chapter 30 - Beyond the Oak". And all subsequent chapter indexes are now wrong.

I haven't looked at any code, but I suspect an "off-by-1" type of error somewhere, since playing starts at the beginning of the file, but uses chapter metadata starting at the second chapter (in file 2).

Apart from this issue audiobookshelf appears to parse/scan the .m4b files correctly, thus it appears to be a bug in audiobookshelf.

No errors in the logs, even on Debug log level.

Books consisting of only one .m4b file has no chapter issues.

Steps to reproduce the issue

  1. Add an audiobook in .m4b format, with at least two tracks. Each track must probably contain more than one chapter and metadata about the chapters.
  2. Observe that the first chapter of the second track isn't listed in audiobookshelf
  3. Observe that playing the book starting at the first chapter in the second file will start playing at the beginning of the file, but the chapter metadata is wrong. Skipping to next chapter goes to the wrong timestamp.

Audiobookshelf version

v2.1.0

How are you running audiobookshelf?

Docker

Originally created by @abstrakct on GitHub (Jul 24, 2022). ### Describe the issue I have some audiobooks that consists of two .m4b files. Each file contains many chapters. Audiobookshelf detects and scans them correctly, but in the chapter list for the book (in audiobookshelf) the first chapter of file 2 is missing. When playing the book in audiobookshelf, all chapters from file 1 are correct, but the first chapter of file 2 has the name of the second chapter in file 2. Screenshots probably explain it better: File 2 metadata: ![2022-07-24-13-10-01](https://user-images.githubusercontent.com/182898/180644331-167dcf9d-7632-4caf-a36e-5f98b42dfc22.png) But in audiobookshelf: ![2022-07-24-13-11-24](https://user-images.githubusercontent.com/182898/180644367-ae0105b5-f6b8-4421-9ef1-055da70d2121.png) As you can see, "Chapter 30 - Beyond the Oak" is missing in audiobookshelf -- but if I play the book and skip to what audiobookshelf thinks is "Chapter 31 - Assurances" it starts playing at the beginning of file 2, at "Chapter 30 - Beyond the Oak". And all subsequent chapter indexes are now wrong. I haven't looked at any code, but I suspect an "off-by-1" type of error somewhere, since playing starts at the beginning of the file, but uses chapter metadata starting at the second chapter (in file 2). Apart from this issue audiobookshelf appears to parse/scan the .m4b files correctly, thus it appears to be a bug in audiobookshelf. No errors in the logs, even on Debug log level. Books consisting of only one .m4b file has no chapter issues. ### Steps to reproduce the issue 1. Add an audiobook in .m4b format, with at least two tracks. Each track must probably contain more than one chapter and metadata about the chapters. 2. Observe that the first chapter of the second track isn't listed in audiobookshelf 3. Observe that playing the book starting at the first chapter in the second file will start playing at the beginning of the file, but the chapter metadata is wrong. Skipping to next chapter goes to the wrong timestamp. ### Audiobookshelf version v2.1.0 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:12:33 +02:00
adam closed this issue 2026-04-24 23:12:34 +02:00
Author
Owner

@advplyr commented on GitHub (Jul 24, 2022):

Can you share the full chapters of both files then the full chapters that audiobookshelf parsed?

The way abs handles merging chapters between multiple files may be the reason for this but I need all the data.

@advplyr commented on GitHub (Jul 24, 2022): Can you share the full chapters of both files then the full chapters that audiobookshelf parsed? The way abs handles merging chapters between multiple files may be the reason for this but I need all the data.
Author
Owner

@abstrakct commented on GitHub (Jul 27, 2022):

Sure, from mediainfo:

file 1:
2022-07-27-19-50-34

file 2:
2022-07-27-19-51-07

And in ABS:

2022-07-27-19-55-53

2022-07-27-19-56-25

@abstrakct commented on GitHub (Jul 27, 2022): Sure, from mediainfo: file 1: ![2022-07-27-19-50-34](https://user-images.githubusercontent.com/182898/181333535-13f3a5b3-0b1c-42de-b0a8-49abc0c66d0a.png) file 2: ![2022-07-27-19-51-07](https://user-images.githubusercontent.com/182898/181334093-2346939d-4ea8-48f3-a718-9c23ff6a63f0.png) And in ABS: ![2022-07-27-19-55-53](https://user-images.githubusercontent.com/182898/181340261-41d59cd1-1144-49af-af1b-20b77c86c6df.png) ![2022-07-27-19-56-25](https://user-images.githubusercontent.com/182898/181340278-bfebd28f-fa81-45fc-97ae-6d09561b74ab.png)
Author
Owner

@advplyr commented on GitHub (Jul 31, 2022):

Fixed in v2.1.1

It was checking if there was already a chapter with the same start time and ignoring it. This was causing the 0:00 start time in the second book to get ignored. Fixed now.

@advplyr commented on GitHub (Jul 31, 2022): Fixed in [v2.1.1](https://github.com/advplyr/audiobookshelf/releases/tag/v2.1.1) It was checking if there was already a chapter with the same start time and ignoring it. This was causing the 0:00 start time in the second book to get ignored. Fixed now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#544