Skip to content

Fix cover art embedded as a plain video stream - #219

Open
kgrubb wants to merge 2 commits into
LumePart:devfrom
kgrubb:fix/cover-art-attached-pic
Open

Fix cover art embedded as a plain video stream#219
kgrubb wants to merge 2 commits into
LumePart:devfrom
kgrubb:fix/cover-art-attached-pic

Conversation

@kgrubb

@kgrubb kgrubb commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This fixes embedded cover art for non-MP3 output such as M4A. ffmpeg currently re-encodes the image as a normal video stream. Copying it and setting attached_pic makes players and library scanners recognize it as album art.

Verified with ffprobe on M4A output:

before: codec_name=h264   attached_pic=0
after:  codec_name=mjpeg  attached_pic=1

@kgrubb
kgrubb force-pushed the fix/cover-art-attached-pic branch from 4d83aad to 82239f3 Compare August 6, 2026 15:39
@kgrubb kgrubb changed the title Fix cover art being embedded as a plain video stream Fix cover art embedded as a plain video stream Aug 6, 2026
@kgrubb
kgrubb force-pushed the fix/cover-art-attached-pic branch from 82239f3 to 3882304 Compare August 6, 2026 16:06
@Piero-93

Copy link
Copy Markdown

This fixes more than the title suggests: besides m4a, it also gets flac working (the image was silently dropped there) and stops mp3 from storing a re-encoded png.

Two things you may want to fold in:

  1. The picture type stays 0 ("other") rather than 3 ("front cover"). Adding "metadata:s:v": []string{"title=Album cover", "comment=Cover (front)"} gives type 3.
  2. c:v copy can cost the whole track: the cached file is named .jpg but holds whatever the CDN served, and a WebP under that name fails the mp4 muxer (Could not find tag for codec webp in stream Wrong track added to playlist #1), which makes saveVideo return false. c:v mjpeg handles that case and re-encoding a still image is cheap.

Heads-up on overlap: the cover only becomes an ffmpeg input inside the track.CoverPath == "" branch, and loadCustomTracks fills CoverPath from the playlist cache — so for playlists imported through the web UI there is no picture stream for attached_pic to flag in the first place. I opened #230 for that, which ends up covering this ground too. Either order works for me: I can rebase on top of this one, or drop the overlapping part if this gets merged first.

kgrubb and others added 2 commits August 20, 2026 22:14
ffmpeg was re-encoding cover art as a normal video stream, so players did
not recognize it as album art. Copy the image and mark it as attached_pic.
Mark the picture as a front cover via stream metadata, and re-encode
as mjpeg so a WebP cached under a .jpg name does not break the muxer.
@kgrubb
kgrubb force-pushed the fix/cover-art-attached-pic branch from 3882304 to c9a1c5a Compare August 21, 2026 02:15
@kgrubb

kgrubb commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

good catches, thanks! folded both of those recommendations into this branch. Regarding the overlap with #230, either order works for me. Happy to rebase or drop the overlapping part if that one lands first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants