[Bug]: Very large M4B file not able to have metadata embedded #2891

Closed
opened 2026-04-25 00:11:38 +02:00 by adam · 2 comments
Owner

Originally created by @anakinsleftleg on GitHub (Jul 14, 2025).

What happened?

I wanted to update the chapters on this massive multi-work collection. It comes as one file. I'm able to set the chapters in ABS but when I want to embed the metadata, it fails with the following debug output. I admit that i've tried using tone manually and it produced the same problem. I've also tried ffmpeg directly and wasn't able to get it to work. also tried MP4box and same. nothing seems to be able to write to this file without either corrupting it as below, or simply not applying the chapter data. Logs are below.

I was thinking, for files like this, which there are numerous COLLECTED WORKS audiobooks, it would be nice to have a decent gui to have all the chapters there (which you already have) and then allow to split the file into multiple smaller files at specific chapter positions while retaining the bookmarks. basically the reverse of the "combine into a single m4b file" function.

This doesn't have anything to do with this request, and is out of scope, but I would like to be able to split these collected works files into their separate books and use each of those with their correct chapters as individual entries in the library.

What did you expect to happen?

Metadata to be embedded without error.

Steps to reproduce the issue

  1. Have a 7.45gb M4B file and try to update the metadata/chapters.

Audiobookshelf version

2.25.1

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Windows

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

None

Logs

2025-07-13 21:08:21.094

INFO

[AudioMetadataManager] Starting metadata embed task Embedding metadata in audiobook "The Mark Twain Complete Collection".

2025-07-13 21:08:21.110

DEBUG

[AudioMetadataManager] Target directory /audiobooks/Mark Twain/The Mark Twain Complete Collection writable: true

2025-07-13 21:08:21.141

DEBUG

[ffmpegHelpers] Wrote /metadata/cache/items/179db0cb-e1db-4ee9-aca7-4405132959d1/ffmetadata.txt

2025-07-13 21:11:47.101

DEBUG

[AudioMetadataManager] Backed up audio file at "/metadata/cache/items/179db0cb-e1db-4ee9-aca7-4405132959d1/The Mark Twain Complete Collection - Mark Twain - Various.m4b"

2025-07-13 21:11:47.115

DEBUG

[ffmpegHelpers] Spawned Ffmpeg with command: ffmpeg -i /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b -i /metadata/cache/items/179db0cb-e1db-4ee9-aca7-4405132959d1/ffmetadata.txt -i /audiobooks/Mark Twain/The Mark Twain Complete Collection/cover.jpg -y -map 0:a -map_metadata 1 -map_metadata 0 -map_chapters 1 -c copy -metadata track=1 -f mp4 -map 2:v -disposition:v:0 attached_pic -metadata:s:v title=Cover -metadata:s:v comment=Cover /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.tmp.m4b

2025-07-13 21:11:47.581

ERROR

Error adding cover image and metadata: Error: ffmpeg exited with code 183: Error opening input file /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b. Error opening input files: Invalid data found when processing input at ChildProcess.<anonymous> (/app/server/libs/fluentFfmpeg/processor.js:178:22) at ChildProcess.emit (node:events:524:28) at ChildProcess._handle.onexit (node:internal/child_process:293:12)

2025-07-13 21:11:47.581

ERROR

ffmpeg stdout:

2025-07-13 21:11:47.582

ERROR

ffmpeg stderr: ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 14.2.0 (Alpine 14.2.0) configuration: --prefix=/usr --disable-librtmp --disable-lzma --disable-static --disable-stripping --enable-avfilter --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libmp3lame --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librist --enable-libsoxr --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-lto=auto --enable-lv2 --enable-openssl --enable-pic --enable-postproc --enable-pthreads --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan --optflags=-O3 --enable-libjxl --enable-libsvtav1 --enable-libvpl libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc 57. 3.100 / 57. 3.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x738cd3dea640] moov atom not found [in#0 @ 0x738ccfab6980] Error opening input: Invalid data found when processing input Error opening input file /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b. Error opening input files: Invalid data found when processing input

2025-07-13 21:11:47.582

ERROR

[AudioMetadataManager] Failed to tag audio file "/audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b" Error: ffmpeg exited with code 183: Error opening input file /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b. Error opening input files: Invalid data found when processing input at ChildProcess.<anonymous> (/app/server/libs/fluentFfmpeg/processor.js:178:22) at ChildProcess.emit (node:events:524:28) at ChildProcess._handle.onexit (node:internal/child_process:293:12)

2025-07-13 21:11:47.589

DEBUG

[AudioMetadataManager] Task finished and no tasks remain in queue

Additional Notes

No response

Originally created by @anakinsleftleg on GitHub (Jul 14, 2025). ### What happened? I wanted to update the chapters on this massive multi-work collection. It comes as one file. I'm able to set the chapters in ABS but when I want to embed the metadata, it fails with the following debug output. I admit that i've tried using `tone` manually and it produced the same problem. I've also tried ffmpeg directly and wasn't able to get it to work. also tried MP4box and same. nothing seems to be able to write to this file without either corrupting it as below, or simply not applying the chapter data. Logs are below. I was thinking, for files like this, which there are numerous COLLECTED WORKS audiobooks, it would be nice to have a decent gui to have all the chapters there (which you already have) and then allow to split the file into multiple smaller files at specific chapter positions while retaining the bookmarks. basically the reverse of the "combine into a single m4b file" function. This doesn't have anything to do with this request, and is out of scope, but I would like to be able to split these collected works files into their separate books and use each of those with their correct chapters as individual entries in the library. ### What did you expect to happen? Metadata to be embedded without error. ### Steps to reproduce the issue 1. Have a 7.45gb M4B file and try to update the metadata/chapters. ### Audiobookshelf version 2.25.1 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Windows ### If the issue is being seen in the UI, what browsers are you seeing the problem on? None ### Logs ```shell 2025-07-13 21:08:21.094 INFO [AudioMetadataManager] Starting metadata embed task Embedding metadata in audiobook "The Mark Twain Complete Collection". 2025-07-13 21:08:21.110 DEBUG [AudioMetadataManager] Target directory /audiobooks/Mark Twain/The Mark Twain Complete Collection writable: true 2025-07-13 21:08:21.141 DEBUG [ffmpegHelpers] Wrote /metadata/cache/items/179db0cb-e1db-4ee9-aca7-4405132959d1/ffmetadata.txt 2025-07-13 21:11:47.101 DEBUG [AudioMetadataManager] Backed up audio file at "/metadata/cache/items/179db0cb-e1db-4ee9-aca7-4405132959d1/The Mark Twain Complete Collection - Mark Twain - Various.m4b" 2025-07-13 21:11:47.115 DEBUG [ffmpegHelpers] Spawned Ffmpeg with command: ffmpeg -i /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b -i /metadata/cache/items/179db0cb-e1db-4ee9-aca7-4405132959d1/ffmetadata.txt -i /audiobooks/Mark Twain/The Mark Twain Complete Collection/cover.jpg -y -map 0:a -map_metadata 1 -map_metadata 0 -map_chapters 1 -c copy -metadata track=1 -f mp4 -map 2:v -disposition:v:0 attached_pic -metadata:s:v title=Cover -metadata:s:v comment=Cover /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.tmp.m4b 2025-07-13 21:11:47.581 ERROR Error adding cover image and metadata: Error: ffmpeg exited with code 183: Error opening input file /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b. Error opening input files: Invalid data found when processing input at ChildProcess.<anonymous> (/app/server/libs/fluentFfmpeg/processor.js:178:22) at ChildProcess.emit (node:events:524:28) at ChildProcess._handle.onexit (node:internal/child_process:293:12) 2025-07-13 21:11:47.581 ERROR ffmpeg stdout: 2025-07-13 21:11:47.582 ERROR ffmpeg stderr: ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 14.2.0 (Alpine 14.2.0) configuration: --prefix=/usr --disable-librtmp --disable-lzma --disable-static --disable-stripping --enable-avfilter --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libmp3lame --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librist --enable-libsoxr --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-lto=auto --enable-lv2 --enable-openssl --enable-pic --enable-postproc --enable-pthreads --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan --optflags=-O3 --enable-libjxl --enable-libsvtav1 --enable-libvpl libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc 57. 3.100 / 57. 3.100 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x738cd3dea640] moov atom not found [in#0 @ 0x738ccfab6980] Error opening input: Invalid data found when processing input Error opening input file /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b. Error opening input files: Invalid data found when processing input 2025-07-13 21:11:47.582 ERROR [AudioMetadataManager] Failed to tag audio file "/audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b" Error: ffmpeg exited with code 183: Error opening input file /audiobooks/Mark Twain/The Mark Twain Complete Collection/The Mark Twain Complete Collection - Mark Twain - Various.m4b. Error opening input files: Invalid data found when processing input at ChildProcess.<anonymous> (/app/server/libs/fluentFfmpeg/processor.js:178:22) at ChildProcess.emit (node:events:524:28) at ChildProcess._handle.onexit (node:internal/child_process:293:12) 2025-07-13 21:11:47.589 DEBUG [AudioMetadataManager] Task finished and no tasks remain in queue ``` ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:11:38 +02:00
adam closed this issue 2026-04-25 00:11:38 +02:00
Author
Owner

@advplyr commented on GitHub (Jul 14, 2025):

I don't think this has to do with the file size. If every other tool has failed to work with this file then my guess is it is corrupt.

I just tested this with an 8GB audiobook (4 copies of War and Peace merged) and it had no issue embedding.

The logs show that ffmpeg can't open the file, so Abs wouldn't be able to split the file even if that feature were added.

There is an open feature request for that though: https://github.com/advplyr/audiobookshelf/issues/1356

@advplyr commented on GitHub (Jul 14, 2025): I don't think this has to do with the file size. If every other tool has failed to work with this file then my guess is it is corrupt. I just tested this with an 8GB audiobook (4 copies of War and Peace merged) and it had no issue embedding. The logs show that ffmpeg can't open the file, so Abs wouldn't be able to split the file even if that feature were added. There is an open feature request for that though: https://github.com/advplyr/audiobookshelf/issues/1356
Author
Owner

@anakinsleftleg commented on GitHub (Jul 17, 2025):

@advplyr I wanted to give you an update. I have no idea what changed, other than filename but there was nothing wrong with that to begin with (length or anything). Applying the Quick Embed or Full backup embed both work now but with a significant caveat!!

Your command to apply metadata will apply chapters in both standards (Nero (Menu#2) and QuickTime (Menu#1)). The problem is that Nero only supports 255 maximum chapters. QuickTime as far as I know has no limit. But most players will default to the Nero listing if it exists (like VLC). If it doesn't exist, it will use the QT chapters. A tool like MediaInfo (available as console app or gui) will show both types or one or the other. It only shows up to 512 of QT chapters even if there are more, which can be confirmed by ffprobe -i input.m4b -show_chapters.

My point in all this is the following. If the chapter count exceeds 255, I would recommend that audiobookshelf uses a slightly modified version of the metadata command which disables the Nero chapters. Insert -movflags disable_chpl into the command args to do this. So numChapters > 255 then use that, if 255 or less, no change needed to the command. It will populate both types of chapters.

Current command:

ffmpeg -i input.m4b -i ffmetadata.txt -i cover.jpg -y -map 0:a -map_metadata 1 -map_metadata 0 -map_chapters 1 -c copy -metadata track=1 -f mp4 -map 2:v -disposition:v:0 attached_pic -metadata:s:v title=Cover -metadata:s:v comment=Cover output.m4b

Modified command for >255 chapters:

ffmpeg -i input.m4b -i ffmetadata.txt -i cover.jpg -y -map 0:a -map_metadata 1 -map_metadata 0 -map_chapters 1 -c copy -movflags disable_chpl -metadata track=1 -f mp4 -map 2:v -disposition:v:0 attached_pic -metadata:s:v title=Cover -metadata:s:v comment=Cover output.m4b

Also, one of the things I noticed and didn't see anywhere as to why that is is the fact that you have -map_metadata 1 -map_metadata 0 which would populate the metadata with info from ABS first then overwrite it and fill in any missing fields with the original file values. To me, it seems like if anything it should be 0 first then 1 last so that the ABS metadata overwrites anything from the file that is common. Or even just the ABS data only, but I understand there might be reasons for safety to have both. Still, I would want the ABS stuff to always take precedent which means coming last, for any common fields.

@anakinsleftleg commented on GitHub (Jul 17, 2025): @advplyr I wanted to give you an update. I have no idea what changed, other than filename but there was nothing wrong with that to begin with (length or anything). Applying the Quick Embed or Full backup embed both work now but with a _significant_ caveat!! Your command to apply metadata will apply chapters in both standards (Nero (Menu#2) and QuickTime (Menu#1)). The problem is that Nero only supports 255 maximum chapters. QuickTime as far as I know has no limit. But most players will default to the Nero listing if it exists (like VLC). If it doesn't exist, it will use the QT chapters. A tool like MediaInfo (available as console app or gui) will show both types or one or the other. It only shows up to 512 of QT chapters even if there are more, which can be confirmed by `ffprobe -i input.m4b -show_chapters`. My point in all this is the following. If the chapter count exceeds 255, I would recommend that audiobookshelf uses a slightly modified version of the metadata command which disables the Nero chapters. Insert `-movflags disable_chpl` into the command args to do this. So numChapters > 255 then use that, if 255 or less, no change needed to the command. It will populate both types of chapters. Current command: ```bash ffmpeg -i input.m4b -i ffmetadata.txt -i cover.jpg -y -map 0:a -map_metadata 1 -map_metadata 0 -map_chapters 1 -c copy -metadata track=1 -f mp4 -map 2:v -disposition:v:0 attached_pic -metadata:s:v title=Cover -metadata:s:v comment=Cover output.m4b ``` Modified command for >255 chapters: ```bash ffmpeg -i input.m4b -i ffmetadata.txt -i cover.jpg -y -map 0:a -map_metadata 1 -map_metadata 0 -map_chapters 1 -c copy -movflags disable_chpl -metadata track=1 -f mp4 -map 2:v -disposition:v:0 attached_pic -metadata:s:v title=Cover -metadata:s:v comment=Cover output.m4b ``` Also, one of the things I noticed and didn't see anywhere as to why that is is the fact that you have `-map_metadata 1 -map_metadata 0` which would populate the metadata with info from ABS first then overwrite it and fill in any missing fields with the original file values. To me, it seems like if anything it should be 0 first then 1 last so that the ABS metadata overwrites anything from the file that is common. Or even just the ABS data only, but I understand there might be reasons for safety to have both. Still, I would want the ABS stuff to always take precedent which means coming last, for any common fields.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2891