[Bug]: Incorrect chapter generation (224 → 25,200) leads to editor crash #2989

Open
opened 2026-04-25 00:12:46 +02:00 by adam · 13 comments
Owner

Originally created by @crammaster on GitHub (Sep 7, 2025).

What happened?

Problem Description:
When I add an audiobook, there is an error in the way chapters are generated. Instead of the expected 224 chapters, the system creates 25,200 chapters. It looks like each chapter gets counted repeatedly from 1 to 224 (e.g. 1 → 224, 2 → 224, …), until it finally stops at 224. With larger audiobooks, this number can easily grow to over 100,000 chapters.

pic1.bmp
pic2.bmp
pic3.bmp
pic4.bmp

Impact:
The real issue starts when I try to edit the chapters:

The page with tens of thousands of chapters never finishes loading.

After some time, the client loses the socket connection.

As a result, functions like “search chapters” or overwriting chapters become unusable.

Suggested Improvement:
A possible workaround would be to paginate the chapter editing page. For example, after every 1,000 chapters the editor could continue on a new page. This would greatly reduce load times and make editing possible again.
In practice, most audiobooks have far fewer than 1,000 chapters, so pagination would not cause any drawback.

What did you expect to happen?

The chapter editor page loads without any problems.

Steps to reproduce the issue

  1. unkown

Audiobookshelf version

v2.29.0

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Linux

If the issue is being seen in the UI, what browsers are you seeing the problem on?

Firefox

Logs


Additional Notes

The audiobooks are in MP3 format from a large audiobook provider.
Before adding them to ABS, I edit them with MP3Tag.
I adjust the track number, title, and author metadata.

Originally created by @crammaster on GitHub (Sep 7, 2025). ### What happened? **Problem Description:** When I add an audiobook, there is an error in the way chapters are generated. Instead of the expected 224 chapters, the system creates 25,200 chapters. It looks like each chapter gets counted repeatedly from 1 to 224 (e.g. 1 → 224, 2 → 224, …), until it finally stops at 224. With larger audiobooks, this number can easily grow to over 100,000 chapters. [pic1.bmp](https://github.com/user-attachments/files/22192663/pic1.bmp) [pic2.bmp](https://github.com/user-attachments/files/22192661/pic2.bmp) [pic3.bmp](https://github.com/user-attachments/files/22192664/pic3.bmp) [pic4.bmp](https://github.com/user-attachments/files/22192662/pic4.bmp) **Impact:** The real issue starts when I try to edit the chapters: The page with tens of thousands of chapters never finishes loading. After some time, the client loses the socket connection. As a result, functions like “search chapters” or overwriting chapters become unusable. **Suggested Improvement:** A possible workaround would be to paginate the chapter editing page. For example, after every 1,000 chapters the editor could continue on a new page. This would greatly reduce load times and make editing possible again. In practice, most audiobooks have far fewer than 1,000 chapters, so pagination would not cause any drawback. ### What did you expect to happen? The chapter editor page loads without any problems. ### Steps to reproduce the issue 1. unkown ### Audiobookshelf version v2.29.0 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Linux ### If the issue is being seen in the UI, what browsers are you seeing the problem on? Firefox ### Logs ```shell ``` ### Additional Notes The audiobooks are in MP3 format from a large audiobook provider. Before adding them to ABS, I edit them with MP3Tag. I adjust the track number, title, and author metadata.
adam added the bug label 2026-04-25 00:12:46 +02:00
Author
Owner

@nichwall commented on GitHub (Sep 7, 2025):

Can you provide logs of how you got that many chapters? There should be scan logs on /metadata/logs/scans

@nichwall commented on GitHub (Sep 7, 2025): Can you provide logs of how you got that many chapters? There should be scan logs on `/metadata/logs/scans`
Author
Owner

@crammaster commented on GitHub (Sep 7, 2025):

2025-09-07.txt
pic5.bmp

Scan was empty, i found this in daily. I added an audiobook and tried to edit the chapters of another audiobook (25k chapters).

@crammaster commented on GitHub (Sep 7, 2025): [2025-09-07.txt](https://github.com/user-attachments/files/22197934/2025-09-07.txt) [pic5.bmp](https://github.com/user-attachments/files/22197935/pic5.bmp) Scan was empty, i found this in daily. I added an audiobook and tried to edit the chapters of another audiobook (25k chapters).
Author
Owner

@Vito0912 commented on GitHub (Sep 7, 2025):

Can you please share a screenshot of the "Manage Tracks".

Image

Please choose a position where there is a situation where the chapters are wrong.

PS: What (potential german) book has 25k chapters xD?

@Vito0912 commented on GitHub (Sep 7, 2025): Can you please share a screenshot of the "Manage Tracks". <img width="877" height="520" alt="Image" src="https://github.com/user-attachments/assets/e910bbe7-ab77-4416-8c8a-3a331e45f009" /> Please choose a position where there is a situation where the chapters are wrong. PS: What (potential german) book has 25k chapters xD?
Author
Owner

@crammaster commented on GitHub (Sep 7, 2025):

Eng:
The tracks are all fine—there are 224 tracks, one for each chapter. But in the chapter overview, the counting is quite strange.
1 -> 224, 2 -> 224, 3 -> 224, ..., 223 -> 224, 224. This is what accounts for this high number of chapters.

Deu:
Mit den Tracks ist alles okay, das sind es die 224 Tracks, für jedes Kapitel eins. Aber in der Kapitelübersicht, zählt er ganz komisch.
1 -> 224, 2 -> 224, 3 -> 224, ..., 223 -> 224, 224. Dadurch kommt diese hohe Anzahl an Kapitels zustande.

pic6.bmp

@crammaster commented on GitHub (Sep 7, 2025): Eng: The tracks are all fine—there are 224 tracks, one for each chapter. But in the chapter overview, the counting is quite strange. 1 -> 224, 2 -> 224, 3 -> 224, ..., 223 -> 224, 224. This is what accounts for this high number of chapters. Deu: Mit den Tracks ist alles okay, das sind es die 224 Tracks, für jedes Kapitel eins. Aber in der Kapitelübersicht, zählt er ganz komisch. 1 -> 224, 2 -> 224, 3 -> 224, ..., 223 -> 224, 224. Dadurch kommt diese hohe Anzahl an Kapitels zustande. [pic6.bmp](https://github.com/user-attachments/files/22198183/pic6.bmp)
Author
Owner

@Vito0912 commented on GitHub (Sep 7, 2025):

Ah, sorry. I just now understand the real issue. My mistake. I thought it was supposed to be 25,200 (yes, there are books with that many chapters, and there have been issues with that number of chapters in the past, so I assumed that was what you meant). But now where I reread, yeah, you cleary stated the actual issue.

The only thing I could imagine is that each file contains the chapter data and ABS reads the chapters from each file. @nichwall Do you know what happens in that case? I do not really work with multiple files.
From the uploaded logs that does not does seem to be the case though.

What you could try is to block the requests that loads the chapters (in another book that has less chapters) and try opening the editor. I am not sure if that will load at all then, but if not you could try to overwrite it with 1 chapter only and then load the chapters from the file again
Edit: Just tried. Does not work :/

What does work is changing the chapters via the API:

POST https://<domain>/audiobookshelf/api/items/<item-id>/chapters
Payload

{"chapters":[]}
@Vito0912 commented on GitHub (Sep 7, 2025): Ah, sorry. I just now understand the real issue. My mistake. I thought it was supposed to be 25,200 (yes, there are books with that many chapters, and there have been issues with that number of chapters in the past, so I assumed that was what you meant). But now where I reread, yeah, you cleary stated the actual issue. The only thing I could imagine is that each file contains the chapter data and ABS reads the chapters from each file. @nichwall Do you know what happens in that case? I do not really work with multiple files. From the uploaded logs that ~~does not~~ does seem to be the case ~~though~~. What you could try is to block the requests that loads the chapters (in another book that has less chapters) and try opening the editor. I am not sure if that will load at all then, but if not you could try to overwrite it with 1 chapter only and then load the chapters from the file again Edit: Just tried. Does not work :/ What does work is changing the chapters via the API: POST `https://<domain>/audiobookshelf/api/items/<item-id>/chapters` Payload ``` {"chapters":[]} ```
Author
Owner

@crammaster commented on GitHub (Sep 7, 2025):

My suspicion was that something was hidden in the tags, but I couldn't find anything with MP3Tag.

What tool could I use to check whether chapter information is stored in the audio files?

@Vito0912
The fact that there are too many chapters doesn't bother me, since I change the chapter information anyway using the "Find Chapters" function. The problem is that if there are more than 20,000 chapters, the page no longer loads correctly, and the connection to the WebSocket breaks.

@crammaster commented on GitHub (Sep 7, 2025): My suspicion was that something was hidden in the tags, but I couldn't find anything with MP3Tag. What tool could I use to check whether chapter information is stored in the audio files? @Vito0912 The fact that there are too many chapters doesn't bother me, since I change the chapter information anyway using the "Find Chapters" function. The problem is that if there are more than 20,000 chapters, the page no longer loads correctly, and the connection to the WebSocket breaks.
Author
Owner

@Vito0912 commented on GitHub (Sep 7, 2025):

The problem is that if there are more than 20,000 chapters, the page no longer loads correctly, and the connection to the WebSocket breaks.

That's probably because the client froze, which caused the websocket connection to drop.

Still, it should not happen that so many chapters are added in the first place.
As a final guess from my side, can you please send the ffprobe of two different files for the same book? (Under Audiotracks, where you clicked manage tracks, click the three dots instead, select more info, and at the top right choose "Probe Audio File")

@Vito0912 commented on GitHub (Sep 7, 2025): > The problem is that if there are more than 20,000 chapters, the page no longer loads correctly, and the connection to the WebSocket breaks. That's probably because the client froze, which caused the websocket connection to drop. Still, it should not happen that so many chapters are added in the first place. As a final guess from my side, can you please send the ffprobe of two different files for the same book? (Under Audiotracks, where you clicked manage tracks, click the three dots instead, select more info, and at the top right choose "Probe Audio File")
Author
Owner

@crammaster commented on GitHub (Sep 7, 2025):

""chapters": [
{
"id": 0,
"time_base": "1/1000",
"start": 0,
"start_time": "0.000000",
"end": 22731,
"end_time": "22.731000",
"tags": {
"title": "Chapter 1"
}
},
{
"id": 1,
"time_base": "1/1000",
"start": 22731,
"start_time": "22.731000",
"end": 234032,
"end_time": "234.032000",
"tags": {
"title": "Chapter 2"
}
},
{
"id": 2,
"time_base": "1/1000",
"start": 234032,
"start_time": "234.032000",
"end": 420651,
"end_time": "420.651000",
"tags": {
"title": "Chapter 3"
}
},
"

Apparently, the files contain chapter information. What tool can I use to remove it? Unfortunately, MP3Tag doesn't work.

@crammaster commented on GitHub (Sep 7, 2025): ""chapters": [ { "id": 0, "time_base": "1/1000", "start": 0, "start_time": "0.000000", "end": 22731, "end_time": "22.731000", "tags": { "title": "Chapter 1" } }, { "id": 1, "time_base": "1/1000", "start": 22731, "start_time": "22.731000", "end": 234032, "end_time": "234.032000", "tags": { "title": "Chapter 2" } }, { "id": 2, "time_base": "1/1000", "start": 234032, "start_time": "234.032000", "end": 420651, "end_time": "420.651000", "tags": { "title": "Chapter 3" } }, " Apparently, the files contain chapter information. What tool can I use to remove it? Unfortunately, MP3Tag doesn't work.
Author
Owner

@nichwall commented on GitHub (Sep 7, 2025):

The only thing I could imagine is that each file contains the chapter data and ABS reads the chapters from each file. @nichwall Do you know what happens in that case? I do not really work with multiple files.
From the uploaded logs that does not does seem to be the case though.

I would need to look at it again, but if I'm remembering correctly the server checks for chapters in the first track (first file), and then will only include chapters from the other files if the chapters are different (i.e. different name or more than a threshold difference in time).

If the same chapters are included in every file, the duplicates should be filtered out.

Some releases will only put the chapter info for all chapters in the first file, some put all chapter info in every file, and some put only the chapters present in the file (the "most correct" in my opinion, but not as common based on reports).

@nichwall commented on GitHub (Sep 7, 2025): > The only thing I could imagine is that each file contains the chapter data and ABS reads the chapters from each file. @nichwall Do you know what happens in that case? I do not really work with multiple files. > From the uploaded logs that ~~does not~~ does seem to be the case ~~though~~. I would need to look at it again, but if I'm remembering correctly the server checks for chapters in the first track (first file), and then will only include chapters from the other files if the chapters are different (i.e. different name or more than a threshold difference in time). If the same chapters are included in every file, the duplicates should be filtered out. Some releases will only put the chapter info for all chapters in the first file, some put all chapter info in every file, and some put only the chapters present in the file (the "most correct" in my opinion, but not as common based on reports).
Author
Owner

@crammaster commented on GitHub (Sep 7, 2025):

""chapters": [ { "id": 0, "time_base": "1/1000", "start": 0, "start_time": "0.000000", "end": 22731, "end_time": "22.731000", "tags": { "title": "Chapter 1" } }, { "id": 1, "time_base": "1/1000", "start": 22731, "start_time": "22.731000", "end": 234032, "end_time": "234.032000", "tags": { "title": "Chapter 2" } }, { "id": 2, "time_base": "1/1000", "start": 234032, "start_time": "234.032000", "end": 420651, "end_time": "420.651000", "tags": { "title": "Chapter 3" } }, "

Apparently, the files contain chapter information. What tool can I use to remove it? Unfortunately, MP3Tag doesn't work.

This was Track 1 from the Audiobook, this is Track 2.

"chapters": [
{
"id": 0,
"time_base": "1/1000",
"start": 0,
"start_time": "0.000000",
"end": 211277,
"end_time": "211.277000",
"tags": {
"title": "Chapter 2"
}
},
{
"id": 1,
"time_base": "1/1000",
"start": 211277,
"start_time": "211.277000",
"end": 397895,
"end_time": "397.895000",
"tags": {
"title": "Chapter 3"
}
},
{
"id": 2,
"time_base": "1/1000",
"start": 397895,
"start_time": "397.895000",
"end": 588810,
"end_time": "588.810000",
"tags": {
"title": "Chapter 4"
}
},

It starts again at ID0 only the rest is different, which is why the chapters are stacked.

Now the big magical question is how do I remove the chapter information.

@crammaster commented on GitHub (Sep 7, 2025): > ""chapters": [ { "id": 0, "time_base": "1/1000", "start": 0, "start_time": "0.000000", "end": 22731, "end_time": "22.731000", "tags": { "title": "Chapter 1" } }, { "id": 1, "time_base": "1/1000", "start": 22731, "start_time": "22.731000", "end": 234032, "end_time": "234.032000", "tags": { "title": "Chapter 2" } }, { "id": 2, "time_base": "1/1000", "start": 234032, "start_time": "234.032000", "end": 420651, "end_time": "420.651000", "tags": { "title": "Chapter 3" } }, " > > Apparently, the files contain chapter information. What tool can I use to remove it? Unfortunately, MP3Tag doesn't work. This was Track 1 from the Audiobook, this is Track 2. "chapters": [ { "id": 0, "time_base": "1/1000", "start": 0, "start_time": "0.000000", "end": 211277, "end_time": "211.277000", "tags": { "title": "Chapter 2" } }, { "id": 1, "time_base": "1/1000", "start": 211277, "start_time": "211.277000", "end": 397895, "end_time": "397.895000", "tags": { "title": "Chapter 3" } }, { "id": 2, "time_base": "1/1000", "start": 397895, "start_time": "397.895000", "end": 588810, "end_time": "588.810000", "tags": { "title": "Chapter 4" } }, It starts again at ID0 only the rest is different, which is why the chapters are stacked. Now the big magical question is how do I remove the chapter information.
Author
Owner

@Vito0912 commented on GitHub (Sep 7, 2025):

This might not work, as I am not sure what Windows removes.
But if you use Windows you should be able to select all files, right click it, go into the properties and iirc there should be a blue label to remove all metadata from the file.
But I am not sure if that includes such metatdata

@Vito0912 commented on GitHub (Sep 7, 2025): This might not work, as I am not sure what Windows removes. But if you use Windows you should be able to select all files, right click it, go into the properties and iirc there should be a blue label to remove all metadata from the file. But I am not sure if that includes such metatdata
Author
Owner

@crammaster commented on GitHub (Sep 7, 2025):

The problem is that neither Windows nor MP3Tag display chapter information. Therefore, I haven't yet come across chapter information in MP3 files.

@crammaster commented on GitHub (Sep 7, 2025): The problem is that neither Windows nor MP3Tag display chapter information. Therefore, I haven't yet come across chapter information in MP3 files.
Author
Owner

@crammaster commented on GitHub (Sep 9, 2025):

I finally figured out the issue – thanks a lot for your help, guys!

What caused it:
The MP3 files had hidden chapter info in them, structured like this:

Track 1 → Chapter ID 0 → Chapter 1 → Chapter ID 1 → Chapter 2 …

Track 2 → Chapter ID 0 → Chapter 2 → Chapter ID 1 → Chapter 3 …

and so on.

Like @nichwall mentioned, ABS checks for chapter data in the files. If the chapters are the same across multiple files, ABS just ignores the duplicates. But since mine were all slightly different, the chapters just kept stacking up – which explains why there were so many of them in the end.

The tool I was using (MP3Tag) doesn’t actually show these chapter tags. But you can get rid of them via "Utils" → "Remove unknown fields". Once they’re gone, the files don’t contain chapter info anymore, and ABS simply uses the track count as chapters.

Big thanks again to @nichwall and @Vito0912 for pointing me in the right direction!

Also, I agree that splitting the chapter view into subpages would make sense once the number of chapters gets too high. If you think I should open a feature request for that, just let me know.

@crammaster commented on GitHub (Sep 9, 2025): I finally figured out the issue – thanks a lot for your help, guys! What caused it: The MP3 files had hidden chapter info in them, structured like this: Track 1 → Chapter ID 0 → Chapter 1 → Chapter ID 1 → Chapter 2 … Track 2 → Chapter ID 0 → Chapter 2 → Chapter ID 1 → Chapter 3 … and so on. Like @nichwall mentioned, ABS checks for chapter data in the files. If the chapters are the same across multiple files, ABS just ignores the duplicates. But since mine were all slightly different, the chapters just kept stacking up – which explains why there were so many of them in the end. The tool I was using (MP3Tag) doesn’t actually show these chapter tags. But you can get rid of them via "Utils" → "Remove unknown fields". Once they’re gone, the files don’t contain chapter info anymore, and ABS simply uses the track count as chapters. Big thanks again to @nichwall and @Vito0912 for pointing me in the right direction! Also, I agree that splitting the chapter view into subpages would make sense once the number of chapters gets too high. If you think I should open a feature request for that, just let me know.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2989