-
Notifications
You must be signed in to change notification settings - Fork 186
Description
I’d like to suggest revisiting #378, which added logic to ignore subsequent VORBIS_COMMENT blocks in FLAC files. Instead of completely discarding later blocks, I propose that Mutagen could also accept tags from subsequent VORBIS_COMMENT blocks if the first one doesn’t contain any comments.
Having multiple VORBIS_COMMENT blocks is indeed against the FLAC specification, which states that a FLAC stream MUST NOT contain more than one such block. However, there are files in the wild that include an empty first block followed by a second block containing all metadata.
Tools like FFmpeg, macOS Finder, and others appear to handle these files gracefully by simply using the tags from the second block. So, while this is technically non-compliant, it seems to be tolerated in practice. I think it would be beneficial for Mutagen to also handle these files more gracefully.
I haven’t yet tested how FFmpeg and others behave with more than two VORBIS_COMMENT blocks or with conflicting tags between them. If there’s general interest in making Mutagen more permissive here, I’m happy to investigate further and prepare a pull request.
I’m attaching a minimal test file where Mutagen reads no tags, while FFmpeg and macOS display them correctly:
$ python3 - <<'PY'
from mutagen import File
f = File("bad_two_vc.flac")
print("Type:", type(f))
print("Tags:", f.tags)
PY
Type: <class 'mutagen.flac.FLAC'>
Tags: []
$ metaflac --list --block-type=VORBIS_COMMENT bad_two_vc.flac
METADATA block #1
type: 4 (VORBIS_COMMENT)
is last: false
length: 40
vendor string: test
comments: 0
METADATA block #2
type: 4 (VORBIS_COMMENT)
is last: false
length: 133
vendor string: Lavf61.7.100
comments: 7
comment[0]: TITLE=Test Title
comment[1]: ARTIST=Test Artist
comment[2]: ALBUM=Test Album
comment[3]: TRACK=1
comment[4]: TRACKTOTAL=11
comment[5]: YEAR=2025
comment[6]: DISC=1
$ ffprobe bad_two_vc.flac
ffprobe version 7.1.1 Copyright (c) 2007-2025 the FFmpeg developers
built with clang version 21.1.1
... truncated ...
Input #0, flac, from 'bad_two_vc.flac':
Metadata:
TITLE : Test Title
ARTIST : Test Artist
ALBUM : Test Album
TRACK : 1
TRACKTOTAL : 11
YEAR : 2025
DISC : 1
Duration: 00:00:01.00, start: 0.000000, bitrate: 67 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
