Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FLAC tag names in FLAC metadata #184

Merged
merged 5 commits into from
Apr 27, 2024
Merged

Use FLAC tag names in FLAC metadata #184

merged 5 commits into from
Apr 27, 2024

Conversation

floehopper
Copy link
Member

In #183 @graue pointed out that FLAC has its own tag names (FLAC FAQ; Vorbis comment docs). This changes the ffmpeg transcoding for FLAC tracks to use those names. However, it's unclear to me whether we also need to change the encoding of the metadata - currently I've left the -write_id3v2 1 & -id3v2_version 3 ffmpeg options in place on the basis that @graue is already able to view the tags on a FLAC track; it was just that the tag names were incorrect.

An initial search of the internet suggests that it might be better to use the metaflac tool to add metadata to a track, but that would be a moderately significant change and it would probably be worth changing MP3 tagging to work in a similar way, i.e. with a specialist command line tool rather than just using ffmpeg.

Fixes #183.

@floehopper floehopper force-pushed the flac-tags branch 2 times, most recently from 9fcce16 to ddf92b9 Compare April 5, 2024 11:00
@floehopper
Copy link
Member Author

@graue @chrislo Do you know anything about the encoding of FLAC tags? i.e. should they be encoded using the ID3v2 format, but just have different names; or should we use some other form of encoding?

@graue
Copy link

graue commented Apr 6, 2024

This is an impressively fast PR!

I don't understand what "encoded using the ID3v2 format" means. The encoding is described in the Vorbis comment doc you linked to. The code you have in production (as of when I bought that album yesterday) appears to be producing correctly encoded tags except for the tag names. Perhaps ffmpeg is quietly ignoring those ID3 related command line arguments when working with a non-MP3 file.

@floehopper
Copy link
Member Author

@graue Thanks.

Perhaps ffmpeg is quietly ignoring those ID3 related command line arguments when working with a non-MP3 file.

Yes, that seems like a likely explanation. I'd like to understand it a bit better before merging this, so I'll try to find some time to dig into it further when I can.

@floehopper
Copy link
Member Author

Sorry for the delay in making progress on this. I've just done some experiments using both ffmpeg and metaflac to add metadata tags to a FLAC file (see below).

Download sample WAV file

wget https://www2.cs.uic.edu/~i101/SoundFiles/StarWars3.wav

Encode FLAC metadata using ffmpeg (without id3 options)

ffmpeg -y -nostats -loglevel 0 -i StarWars3.wav -metadata TITLE="Star Wars" -codec:a flac -f flac StarWars3.ffmpeg.flac
metaflac --show-all-tags StarWars3.ffmpeg.flac
TITLE=Star Wars
encoder=Lavf61.1.100

Encode FLAC metadata using ffmpeg (with id3 options)

ffmpeg -y -nostats -loglevel 0 -i StarWars3.wav -write_id3v2 1 -id3v2_version 3 -metadata TITLE="Star Wars" -codec:a flac -f flac StarWars3.ffmpeg.id3.flac
metaflac --show-all-tags StarWars3.ffmpeg.id3.flac
TITLE=Star Wars
encoder=Lavf61.1.100

Encode FLAC metadata using metaflac

ffmpeg -y -nostats -loglevel 0 -i StarWars3.wav -codec:a flac -f flac StarWars3.metaflac.flac
metaflac --set-tag "TITLE=Star Wars" StarWars3.metaflac.flac
metaflac --show-all-tags StarWars3.metaflac.flac
encoder=Lavf61.1.100
TITLE=Star Wars

Conclusion

We can continue to use ffmpeg and its metadata option and the write_id3v2 & id3v2_version options will be ignored. However, I think it would be less confusing not to include the the write_id3v2 & id3v2_version options in the ffmpeg command for FLAC files. So I will change this PR accordingly.

Instead of the `format` param. This is more consistent with what we're
doing in other methods on this class.
I'm planning on using this method for non-ID3 tags.
I'm planning on using this method for non-ID3 tags.
In #183 @graue pointed out that FLAC has its own tag names [1,2]. This
changes the ffmpeg transcoding for FLAC tracks to use those names.

After some experiments [3], I have determined that the `write_id3v2` &
`id3v2_version` muxer options are not needed (they are ignored) when
writing metadata to a FLAC file and so I have removed them from the
generated `ffmpeg` command in that case in order to make the command
less confusing.

Fixes #183.

[1]: https://xiph.org/flac/faq.html#general__tagging
[2]: https://xiph.org/vorbis/doc/v-comment.html
[3]: #184 (comment)
@floehopper
Copy link
Member Author

We can continue to use ffmpeg and its metadata option and the write_id3v2 & id3v2_version options will be ignored. However, I think it would be less confusing not to include the the write_id3v2 & id3v2_version options in the ffmpeg command for FLAC files. So I will change this PR accordingly.

Addressed in 1ce8257.

@floehopper floehopper merged commit 4b70a8e into main Apr 27, 2024
2 checks passed
@floehopper floehopper deleted the flac-tags branch April 27, 2024 10:38
@floehopper
Copy link
Member Author

@graue I've just merged & deployed this change. However, for now it will only fix tracks which are transcoded after the change. If you point me at a few tracks, I can force re-transcoding for them and you can tell me whether it's working for you. Once we're happy it's working, we'll re-transcode all the tracks across the site. Thanks again for reporting the problem and for your patience!

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.

Wrong FLAC tags
2 participants