advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
6.65k stars 470 forks source link

[Bug]: webp covers (either in folder structure or embedded in files) make the metadata embedder and the m4b conversion tool fail #3379

Closed kuldan5853 closed 1 month ago

kuldan5853 commented 1 month ago

What happened?

When you use a .webp image as a cover, it will show correctly on the ABS GUI - however, the metadata manager cannot embed or modify it in files (which also means that m4b conversions fail due to the embed being a step in the process)

What did you expect to happen?

.webp working the same as .png or .jpg files - or at least failing gracefully with a clear error message (auto conversion would be perfect of course)

Steps to reproduce the issue

  1. Try to convert a book to m4b that uses an .webp file as the cover
  2. You can also try to simply embed the metadata to the file instead

Audiobookshelf version

v2.12.3

How are you running audiobookshelf?

Windows Tray App

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

Input #2, webp_pipe, from 'C:/Audiobookshelf/Data/metadata/items/f9dc2bd8-7993-4559-a60a-144588da9dee/cover.webp':
  Duration: N/A, bitrate: N/A
  Stream #2:0: Video: webp, yuva420p(tv, bt470bg/unknown/unknown), 1000x992, 25 fps, 25 tbr, 25 tbn
[mp4 @ 000001ea22069dc0] Could not find tag for codec webp in stream #1, codec not currently supported in container
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:1 -- 
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #2:0 -> #0:1 (copy)
    Last message repeated 1 times
 (    at FfmpegCommand.<anonymous> (C:\snapshot\audiobookshelf\server\utils\ffmpegHelpers.js))
[2024-09-04 14:03:44.934] ERROR: [AbMergeManager] Failed to write metadata to file "C:\Audiobookshelf\Data\metadata\cache\items\f9dc2bd8-7993-4559-a60a-144588da9dee\087 - Der boese Geist vom Waisenhaus.m4b" (    at AbMergeManager.runAudiobookMerge (C:\snapshot\audiobookshelf\server\managers\AbMergeManager.js))
[2024-09-04 14:03:44.934] WARN: [AbMergeManager] Killing ffmpeg process for task f75b80e9-3a95-42e0-9f9c-0babfd59400a (    at AbMergeManager.removeTask (C:\snapshot\audiobookshelf\server\managers\AbMergeManager.js))
[2024-09-04 14:03:45.462] INFO: [AbMergeManager] Deleted target file C:\Audiobookshelf\Data\metadata\cache\items\f9dc2bd8-7993-4559-a60a-144588da9dee\087 - Der boese Geist vom Waisenhaus.m4b
[2024-09-04 14:03:45.469] INFO: [AbMergeManager] Deleted ffmetadata file C:\Audiobookshelf\Data\metadata\cache\items\f9dc2bd8-7993-4559-a60a-144588da9dee\ffmetadata.txt

Additional Notes

No response

kuldan5853 commented 1 month ago

My suggestion would be to detect the usage of .webp covers and simply skipping the embed step for them as a quick bypass solution.

Longer term, maybe change the ABS interface so that .webp covers are not accepted to be set in the first place (and a notice is given to the user that they should please use a png or jpg file instead)

mikiher commented 1 month ago

I'll take a look. I'm pretty sure it's easily fixable.

mikiher commented 1 month ago

I didn't dig too deeply into this, but it looks like webp isn't supported in a mp4 container.

What I can do is to convert the input webp into jpeg or png on-the-fly and embed that into the file. Is that an acceptable solution?

kuldan5853 commented 1 month ago

What I can do is to convert the input webp into jpeg or png on-the-fly and embed that into the file. Is that an acceptable solution?

If that's possible I think that would be the best possible solution as it achieves the desired result (an embedded cover) and does what the user expects (embedding a cover that worked in ABS without a warning message)

github-actions[bot] commented 1 month ago

Fixed in v2.13.4.