[Bug]: M4B creation fails to do out of memory error #3046

Closed
opened 2026-04-25 00:13:15 +02:00 by adam · 6 comments
Owner

Originally created by @plz12345 on GitHub (Oct 21, 2025).

What happened?

ffmpeg claims to be unable to open the metadata file. I tried purging the items cache, to have the app re-create it (I hope?). But no joy there. I have no memory constraints on the container and plenty of available RAM on the host. The ffmetadata.txt file does get created, and doesn't appear to have any issues. It's only 12KB during the process.

The "failed to open" error seems odd. I do see this file being created as part of the process, and it does have content. I tried multiple times, and I also tried removing the rich text formatting of the book description. Other books seem to merge much more quickly than this failing one. Normal merges take less than a minute, whereas this one takes a few minutes.

I've successfully created M4B's with other books in my library, so it appears to be something specific to this one book. I'd be happy to try and manually run the commands, if they are documented anywhere, to see if I can get better error output from whatever ffmpeg is choking on.

What did you expect to happen?

Merge the audiobook successfully, or at least leave it in a resumable state where it failed. Trying again, at this point, means re-merging all the audio, just to get to the end state where it fails again.

Steps to reproduce the issue

  1. Attempt to merge MP3 audiobook to M4B audiobook.

Audiobookshelf version

v2.30.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

2025-10-21 12:41:12.505 INFO Start m4b encode for f60bd042-25ff-4f15-a1a8-06644cd9f711 - TaskId: 244ee89b-88ed-49f2-a421-ec1ce40a14f3

2025-10-21 12:48:12.430 ERROR Error adding cover image and metadata: Error: ffmpeg exited with code 244: Error opening input file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/ffmetadata.txt. Error opening input files: Out of memory 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-10-21 12:48:12.430 ERROR ffmpeg stdout:

2025-10-21 12:48:12.430 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 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/The Girl from Widow Hills.m4b': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 encoder : Lavf60.16.100 Duration: 09:57:11.77, start: 0.000000, bitrate: 68 kb/s Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 66 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] [ffmetadata @ 0x15238d197380] Chapter end time 56309 before start 2055000 [in#1 @ 0x15238af41a00] Error opening input: Out of memory Error opening input file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/ffmetadata.txt. Error opening input files: Out of memory

2025-10-21 12:48:12.430 ERROR [AbMergeManager] Failed to embed metadata in file "/metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/The Girl from Widow Hills.m4b"

2025-10-21 12:48:12.430 INFO [AbMergeManager] Removing task 244ee89b-88ed-49f2-a421-ec1ce40a14f3

2025-10-21 12:48:12.430 WARN [AbMergeManager] Killing ffmpeg process for task 244ee89b-88ed-49f2-a421-ec1ce40a14f3

2025-10-21 12:48:12.931 INFO [AbMergeManager] Deleted target file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/The Girl from Widow Hills.m4b

2025-10-21 12:48:12.931 INFO [AbMergeManager] Deleted ffmetadata file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/ffmetadata.txt

Additional Notes

No response

Originally created by @plz12345 on GitHub (Oct 21, 2025). ### What happened? ffmpeg claims to be unable to open the metadata file. I tried purging the items cache, to have the app re-create it (I hope?). But no joy there. I have no memory constraints on the container and plenty of available RAM on the host. The ffmetadata.txt file does get created, and doesn't appear to have any issues. It's only 12KB during the process. The "failed to open" error seems odd. I do see this file being created as part of the process, and it does have content. I tried multiple times, and I also tried removing the rich text formatting of the book description. Other books seem to merge much more quickly than this failing one. Normal merges take less than a minute, whereas this one takes a few minutes. I've successfully created M4B's with other books in my library, so it appears to be something specific to this one book. I'd be happy to try and manually run the commands, if they are documented anywhere, to see if I can get better error output from whatever ffmpeg is choking on. ### What did you expect to happen? Merge the audiobook successfully, or at least leave it in a resumable state where it failed. Trying again, at this point, means re-merging all the audio, just to get to the end state where it fails again. ### Steps to reproduce the issue 1. Attempt to merge MP3 audiobook to M4B audiobook. ### Audiobookshelf version v2.30.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 2025-10-21 12:41:12.505 INFO Start m4b encode for f60bd042-25ff-4f15-a1a8-06644cd9f711 - TaskId: 244ee89b-88ed-49f2-a421-ec1ce40a14f3 2025-10-21 12:48:12.430 ERROR Error adding cover image and metadata: Error: ffmpeg exited with code 244: Error opening input file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/ffmetadata.txt. Error opening input files: Out of memory 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-10-21 12:48:12.430 ERROR ffmpeg stdout: 2025-10-21 12:48:12.430 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 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/The Girl from Widow Hills.m4b': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2mp41 encoder : Lavf60.16.100 Duration: 09:57:11.77, start: 0.000000, bitrate: 68 kb/s Stream #0:0[0x1](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 66 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] [ffmetadata @ 0x15238d197380] Chapter end time 56309 before start 2055000 [in#1 @ 0x15238af41a00] Error opening input: Out of memory Error opening input file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/ffmetadata.txt. Error opening input files: Out of memory 2025-10-21 12:48:12.430 ERROR [AbMergeManager] Failed to embed metadata in file "/metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/The Girl from Widow Hills.m4b" 2025-10-21 12:48:12.430 INFO [AbMergeManager] Removing task 244ee89b-88ed-49f2-a421-ec1ce40a14f3 2025-10-21 12:48:12.430 WARN [AbMergeManager] Killing ffmpeg process for task 244ee89b-88ed-49f2-a421-ec1ce40a14f3 2025-10-21 12:48:12.931 INFO [AbMergeManager] Deleted target file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/The Girl from Widow Hills.m4b 2025-10-21 12:48:12.931 INFO [AbMergeManager] Deleted ffmetadata file /metadata/cache/items/f60bd042-25ff-4f15-a1a8-06644cd9f711/ffmetadata.txt ``` ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:13:15 +02:00
adam closed this issue 2026-04-25 00:13:15 +02:00
Author
Owner

@Vito0912 commented on GitHub (Oct 21, 2025):

How much RAM does ABS has?
And how many and how big files are you trying to merge?

@Vito0912 commented on GitHub (Oct 21, 2025): How much RAM does ABS has? And how many and how big files are you trying to merge?
Author
Owner

@plz12345 commented on GitHub (Oct 21, 2025):

How much RAM does ABS has? And how many and how big files are you trying to merge?

I don't cap the container's memory at all, nor Docker (running on Unraid). It idles around 1.2GB, and during the attempted merge it does not increase to any significant level. The Docker host has a total of 32GB RAM, and is only using 10GB total across all containers, including this one.

The total size of the MP3's is 288.5MB, and this tool has merged much larger books without issue.

@plz12345 commented on GitHub (Oct 21, 2025): > How much RAM does ABS has? And how many and how big files are you trying to merge? I don't cap the container's memory at all, nor Docker (running on Unraid). It idles around 1.2GB, and during the attempted merge it does not increase to any significant level. The Docker host has a total of 32GB RAM, and is only using 10GB total across all containers, including this one. The total size of the MP3's is 288.5MB, and this tool has merged much larger books without issue.
Author
Owner

@jpeel commented on GitHub (Oct 23, 2025):

I think that the problem isn't truly an OOM (maybe ffmpeg is misreporting that part?), but is Chapter end time 56309 before start 2055000. Check the chapters in your input M4B file and look at the start times listed there and the durations.

@jpeel commented on GitHub (Oct 23, 2025): I think that the problem isn't truly an OOM (maybe ffmpeg is misreporting that part?), but is `Chapter end time 56309 before start 2055000`. Check the chapters in your input M4B file and look at the start times listed there and the durations.
Author
Owner

@plz12345 commented on GitHub (Oct 23, 2025):

The input is MP3, not M4B. Are you saying one of them has bad ID3 tag data?

@plz12345 commented on GitHub (Oct 23, 2025): The input is MP3, not M4B. Are you saying one of them has bad ID3 tag data?
Author
Owner

@nichwall commented on GitHub (Oct 23, 2025):

Can you share a screenshot of the chapter data for the book in ABS or use the network tab in your browser to inspect the full metadata object for the book? It could be that ABS has the wrong chapter information and it's generating the metadata file for embedding incorrectly, but yeah I agree it's actually due to a problem with the chapter metadata and not an OOM.

@nichwall commented on GitHub (Oct 23, 2025): Can you share a screenshot of the chapter data for the book in ABS or use the network tab in your browser to inspect the full metadata object for the book? It could be that ABS has the wrong chapter information and it's generating the metadata file for embedding incorrectly, but yeah I agree it's actually due to a problem with the chapter metadata and not an OOM.
Author
Owner

@plz12345 commented on GitHub (Oct 23, 2025):

I dug deeper, and did find the chapter info to be a bit messed up. What I did to resolve it:

  1. Went into the chapter data in ABS
  2. Cleared that data
  3. Set the data based on MP3 tracks
  4. Re-tried the M4B conversion.
  5. Once this completed (successfully, this time), went back into the ABS chapter data
  6. Used the "lookup" option to re-pull chapter data by ASIN.

Not sure how I ended up in that situation, but I'm glad it was only the one book. Kudos for having the built-in tooling to handle that without having to resort to manual ffmpeg shenanigans.

@plz12345 commented on GitHub (Oct 23, 2025): I dug deeper, and did find the chapter info to be a bit messed up. What I did to resolve it: 1. Went into the chapter data in ABS 2. Cleared that data 3. Set the data based on MP3 tracks 4. Re-tried the M4B conversion. 5. Once this completed (successfully, this time), went back into the ABS chapter data 6. Used the "lookup" option to re-pull chapter data by ASIN. Not sure how I ended up in that situation, but I'm glad it was only the one book. Kudos for having the built-in tooling to handle that without having to resort to manual ffmpeg shenanigans.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3046