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

Support RIFF INFO chunk metadata (AVI, WAV, XMA, xWMA, RMI, DLS) #207

Open
lazka opened this issue Dec 21, 2014 · 21 comments
Open

Support RIFF INFO chunk metadata (AVI, WAV, XMA, xWMA, RMI, DLS) #207

lazka opened this issue Dec 21, 2014 · 21 comments

Comments

@lazka
Copy link
Member

lazka commented Dec 21, 2014

Originally reported by: Freso Fenderson (Bitbucket: Freso, GitHub: Freso)


https://en.wikipedia.org/wiki/Resource_Interchange_File_Format#Use_of_the_INFO_chunk
https://en.wikipedia.org/wiki/Resource_Interchange_File_Format#INFO_chunk_placement_problems
https://en.wikipedia.org/wiki/Resource_Interchange_File_Format#RIFF_Info_Tags

See also discussion downstream in beetbox/beets#1160 and http://tickets.musicbrainz.org/browse/PICARD-653


@lazka
Copy link
Member Author

lazka commented Oct 5, 2015

Original comment by Christoph Reiter (Bitbucket: lazka, GitHub: lazka):


Some thoughts on the API:

Add a RIFFFileType and a RIFFInfoTags for exposing the info block.
RIFFFileType takes either ID3, EasyID3 or RIFFInfoTags as tagging format.

Make RIFFFileType subclasses for WAV, AVI, RMI etc.

One problem regarding RIFFInfoTags is the text encoding of the info block.
Windows uses latin-1 and VLC uses utf-8 for example.

Possible solutions there is to expose the values as bytes or allow passing in a preferred encoding (defaulting to latin-1)

@lazka
Copy link
Member Author

lazka commented Nov 25, 2015

Original comment by Amias Channer (Bitbucket: amias_channer, GitHub: Unknown):


I could really use this functionality and would be happy to help code and test it, i'm new to mutagenx internals so might need some pointers.

I am currently using mutagenx in some code to test an audio playing system and have a library of sample files with which to test it.

@lazka
Copy link
Member Author

lazka commented Nov 25, 2015

Original comment by Christoph Reiter (Bitbucket: lazka, GitHub: lazka):


(Note that you should use mutagen and not mutagenx which was a Python3 fork which is no longer in development)

@andimarafioti
Copy link

I would like to contact Amias Channer in order to work on the wav support. Does anyone here know where I could find him?

@arigit
Copy link

arigit commented Jun 8, 2016

+1 on mutagen support for WAV files. Trying to use python's wave module to find bitsPerSample and sampleRate for WAVs created by ffmpeg from 24-bit flacs, and it fails miserably.

ffmpeg -i CDImage.flac -acodec pcm_s24le output.wav
...
wave.Error: unknown format: 65534

Already using mutagen to extract the same info from FLACs so being able to use it for WAV would be ideal

@jcea
Copy link

jcea commented Jun 20, 2017

I am also interested on this. I have WAV and WMA files I would like to be able to parse. Thanks.

Borewit added a commit to Borewit/mutagen that referenced this issue Aug 15, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 15, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 15, 2017
@Borewit
Copy link
Contributor

Borewit commented Aug 15, 2017

Started initial RIFF/WAVE implementation. I start with being able to read basic stream information such as:

  • sample rate
  • duration
  • bit-depth
  • number of channels

Although this is not an official standard (neither there is a much better alternative), I will store metadata using ID3v2.

I will use MusicBrainz Picard and my own library music-metadata to cross check functionality.

Constructive contribution is more then welcome, I have 0 experience with Python.

Borewit added a commit to Borewit/mutagen that referenced this issue Aug 16, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 16, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 16, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 16, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 16, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 16, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 17, 2017
@Borewit
Copy link
Contributor

Borewit commented Aug 17, 2017

@lazka, can you help me out with some coding?

        self._RiffFile__fileobj.seek(self.__next_offset)
        self._RiffFile__fileobj.write(pack('<4si', id_.ljust(4).encode('ascii'), 0))
        self._RiffFile__fileobj.seek(self.__next_offset)
        chunk = RiffChunkHeader(self._RiffFile__fileobj)
        self[u'RIFF']._update_size(self[u'RIFF'].data_size + chunk.size)

(source: /mutagen/wave.py:190)

I want to access __fileobj declared in the parent (super) class RiffFile. I only get it to work using self._RiffFile__fileobj, and not using self.__fileobj.

@lazka
Copy link
Member Author

lazka commented Aug 17, 2017

Borewit added a commit to Borewit/mutagen that referenced this issue Aug 17, 2017
Borewit added a commit to Borewit/mutagen that referenced this issue Aug 17, 2017
@Borewit
Copy link
Contributor

Borewit commented Aug 18, 2017

@lazka: Thanks!

How to store metadata in RIFF/WAV files is not straight forward thing:

Looks like there are two options (which can be combined):

  1. Store metadata in the RIFF-LIST-INFO chunk
  2. Store metadata in non-standard, but better supported: RIFF/ID3v2.3

There is also some inconsistency in storing the ID3v2.3 chunk, some application use 'id3 ', others use 'ID3 '. This is how some applications handle the RIFF/WAV metadata:

Mp3Tag v2.8 Windows 10 Explorer Foobar 1.3.14 Windows 10 Explorer Media Player
Reads RIFF/LIST-INFO
Writes RIFF/LIST-INFO does not write does not write
Writes RIFF/ID3v2 does not write does not write
Reads RIFF/'id3 '/ID3v2
Reads RIFF/'ID3 '/ID3v2
Writes RIFF/ID3v2 chunk-id 'ID3 ' does not write 'id3 ' does not write

Notice that I did not found a single application which was able read from the RIFF/INFO tag; although it is apparently written in addition to the ID3v2.3 chunk.

Useful stuff:

@lazka
Copy link
Member Author

lazka commented Aug 20, 2017

Looks like there are two options (which can be combined):

[edit: oops misread.. ignore previous]

This is how some applications handle the RIFF/WAV metadata:

Cool, thanks for testing all those.

Last time I checked for AVI I think I remember that VLC and Windows explorer did read the INFO block there. But I might be miss-remembering or it only does so for AVI and not for WAVE.

Ignoring the INFO chunk seems fine for now..

phw pushed a commit to phw/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to phw/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to phw/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to phw/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to Borewit/mutagen that referenced this issue Oct 15, 2019
phw pushed a commit to phw/mutagen that referenced this issue Oct 21, 2019
phw pushed a commit to phw/mutagen that referenced this issue Oct 22, 2019
phw pushed a commit to phw/mutagen that referenced this issue Nov 15, 2019
phw pushed a commit to phw/mutagen that referenced this issue Nov 18, 2019
phw pushed a commit to phw/mutagen that referenced this issue Jan 3, 2020
phw pushed a commit to phw/mutagen that referenced this issue Feb 10, 2020
phw pushed a commit to phw/mutagen that referenced this issue Mar 13, 2020
phw pushed a commit to phw/mutagen that referenced this issue May 3, 2020
@postlund
Copy link

I guess this is related to #538?

@phw
Copy link
Collaborator

phw commented Feb 15, 2023

This was also discussed in #559.

Overall regarding the issue here the proposed patch by @postlund looks mostly good for read support. Encoding support could be improved maybe.

Also this could be extended with some ideas from https://github.com/metabrainz/picard/blob/master/picard/formats/wav.py#L39-L219 for more supported tags and write support.

@StealthyExpertX
Copy link

Is .wav support a thing? If so what is the correct usage import for using mutagen as a module?

I wanted to be able to do something like "from mutagen.mp3 import MP3"
but the wav equivalent.

@phw
Copy link
Collaborator

phw commented Mar 1, 2023

@StealthyExpertX WAVE in general is supported. The easiest way to load a file into mutagen independent of format is:

from mutagen import File

file_path = "./test.wav"
f = File(file_path)

For WAVE f will be of type mutagen.wave.WAVE. You can of course also directly instantiate this class. See also the documentation at https://mutagen.readthedocs.io/en/latest/api/wave.html .

Regarding tags mutagen supports ID3 tags embedded as a RIFF chunk. This is also supported by some media players, e.g. foobar2000, Media Monkey and MP3Tag can read and write those tags. See also the table further up in this ticket.

Not supported right now is reading / writing tags inside an INFO chunk, as e.g. supported by Windows. Adding support for this is what this issue here is about.

It's a rather limited format (rather restricted set of tags, no support for different character encodings), but often the only tagging supported for WAVE files.

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

No branches or pull requests

10 participants