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

Get Metadata from MP3 or WAV files #149

Open
julianxhokaxhiu opened this issue Sep 20, 2020 · 6 comments
Open

Get Metadata from MP3 or WAV files #149

julianxhokaxhiu opened this issue Sep 20, 2020 · 6 comments
Labels

Comments

@julianxhokaxhiu
Copy link

Hi,

I've been tinkering with your libraries, and so far I was able to get the metadata ( Vorbis comments ) out of FLAC files using the onMeta callbacks pared with drflac_init_vorbis_comment_iterator/drflac_next_vorbis_comment functions.

I was looking for something similar on the dr_mp3.h and dr_wav.h decode libraries, but I was not able to find a pattern nor anything that goes near to the terms "tag", "comment" or "metadata".

Would you be able to let me know if the libraries to support at all this functionality?

Thank you in advance,
Julian

@mackron
Copy link
Owner

mackron commented Sep 21, 2020

With dr_wav, you can use drwav_init_*_ex() and implement a callback for the onChunk parameter. That will then let you handle any chunk. See here for more info:

Callback for when drwav_init_ex() finds a chunk.

For dr_mp3 there is no API for extracting metadata, unfortunately.

@julianxhokaxhiu
Copy link
Author

Thank you for the reply :)

I'll to tinker with the dr_wav and let you know how it goes. Meanwhile, do you have a plan on extracting the metadata out of MP3 files too? Audacity for eg. allows you to put some Metadata in the file so I suppose there is some sort of specification out there right? Would it be too complicated for you to be implemented?

Thanks again in advance,
Julian

@julianxhokaxhiu
Copy link
Author

julianxhokaxhiu commented Sep 21, 2020

Allright, so I've made some progress. I am now able to get the chunk content in a buffer, but I have to do some manual parsing to extract what I need. Is there a reference document or something I can use to build this correctly? I'm currently reading chunks on 4KB per callback, not sure if it's the best way.

Thank you in advance for any help, is really appreciated!

//EDIT: Found something http://www.robotplanet.dk/audio/wav_meta_data/

@mackron
Copy link
Owner

mackron commented Sep 21, 2020

Yes, manual passing will be required. Reading in 4KB chunks shouldn't be necessary unless you have some unusual performance requirements. Need to be careful not to read beyond the chunk, the size of which can be extracted from the chunk header passed into the onChunk callback.

This is another reference I've used in the past: https://sites.google.com/site/musicgapi/technical-documents/wav-file-format

For MP3, dr_mp3 actually wraps around minimp3. It would require some manual processing outside of minimp3 to handle the various ID3 tags. The author of minimp3 is maintaining a sort of extended high level version of it called minimp3_ex which detects these tags, but I'm not sure if they're reported back to the application for handling. From what I saw it's just for skipping over them elegantly. I may add support for it at some point, but I not right now.

@julianxhokaxhiu
Copy link
Author

Yes, manual passing will be required. Reading in 4KB chunks shouldn't be necessary unless you have some unusual performance requirements. Need to be careful not to read beyond the chunk, the size of which can be extracted from the chunk header passed into the onChunk callback.

Indeed I figured this out this afternoon but I forgot to actually mention it here, but still thanks for the heads up. I also figured out the way to parse chunks so I'll add my implementation now, should be easy to detect all tags :)

This is another reference I've used in the past: https://sites.google.com/site/musicgapi/technical-documents/wav-file-format

Thanks, again for the heads up!

For MP3, dr_mp3 actually wraps around minimp3. It would require some manual processing outside of minimp3 to handle the various ID3 tags. The author of minimp3 is maintaining a sort of extended high level version of it called minimp3_ex which detects these tags, but I'm not sure if they're reported back to the application for handling. From what I saw it's just for skipping over them elegantly. I may add support for it at some point, but I not right now.

Indeed I notice that most of the code is literally skipping tags and there's no point in the lib actually passing them. Too bad :( Not urgent though. At the moment I'm happy I am able to get them from FLAC, WAV and Ogg files ( using another library ). MP3 can wait and they're not really urgent :) Still thanks, feel free to ping me on this issue ASAP you get something implemented. Cheers!

@raysan5
Copy link
Sponsor

raysan5 commented Sep 24, 2020

Personally, I think it would be interesting to have the possibility to retrieve the ID3 chunk of data from the MP3 file, to allow processing it on user side. Just for reference, here some ID3 tag info: https://en.wikipedia.org/wiki/ID3

EDIT: Investigated a bit about ID3v2.3 (it seems the standard tag) and it's not trivial to process all the possible contained data, ID3v1 placed at the end of the file is way simpler. In any case, it would be nice to get the chunk...

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

No branches or pull requests

3 participants