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

wave: Read metadata from RIFF INFO chunk #538

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

postlund
Copy link

@postlund postlund commented Aug 30, 2021

Metadata seems to be all over the place with WAVE, but files converted with ffmpeg seems to not insert ID3 tags but only in the LIST/INFO chunk. So I've made an attempt implementing support for reading metadata from there and converting it to ID3 tags. Not sure if I've done it OK, so would love some feedback. One thing I'm not sure about is how to deal with is "delete". I'm currently deleting the LIST tag, but I find that to be rather destructive. Any input would be great.

See #207

@phw
Copy link
Collaborator

phw commented Aug 30, 2021

Maybe interesting, there is a read/write implementation for RIFF tags in https://github.com/metabrainz/picard/blob/master/picard/formats/wav.py . I always wanted to submit this in some way to mutagen, but never was sure how to best integrate this. It maybe should work somewhat like ID3v1 is handled, where you can specify on writing ID3v2 whether you also want to write ID3v1 tags as well.

@postlund
Copy link
Author

I guess the implementation in picard is quite similar to what I have done, but I also have the re-mapping step to ID3. Can't say that I have full knowledge nor understanding of the inner workings of ID3 in the context of mutagen, but this should make it possible to save it in whatever version you like. The LIST chunk is/was just transparent and always passed through before and that will happen now as well. But if it's present, it will add an id3 chunk as well, if not already present. Format of that chunk depends on what is specified when saving metadata to file.

try:
# Value is null-terminated and supposed to be ASCII, but not everyone
# respects that and puts unicode in there anyway
value = chunk.read()[:-1].decode("utf-8")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utf-8 is not a safe choice either, though. foobar2k supports utf-8 in RIFF INFO. But Windows not, and will use Windows-1252 instead (or probably whatever encoding the localized version of Windows is using by default).

In the end it's a mess of course, because there is no way to indicate encoding. But maybe trying UTF-8 first and on UnicodeDecodeError retry with Windows-1252.

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