germangb / minimp3-rs

minimp3 rust bindings + wrapper
MIT License
65 stars 20 forks source link

Add option to handle ID3v1 tag #30

Open grhbit opened 3 years ago

grhbit commented 3 years ago

Hi, I used this library through rodio.

But I found decoding operation of some my files were failed even if they are playable on other players. I found that problem of my files, that is ID3v1.

I think that it seems that handling part for ID3v1 tag is not here. How about adding option to handle ID3v1 tag?


More information is here.

According to minimp3's README, mp3dec_decode_frame will skip ID3 data.

The decoder will analyze the input buffer to properly sync with the MP3 stream, and will skip ID3 data, as well as any data which is not valid.

But they do not handle ID3v1 tag in mp3dec_decode_frame.

Hence, decoding some mp3 files having ID3v1 tag fail because they try parse tag data as sound data.

That also mentioned in README of minimp3.

At end of stream just pass rest of the buffer, sync procedure should work even with just 1 frame in stream (except for free format and garbage at the end can mess things up, so id3v1 and ape tags must be removed first).

Here is sample files contain ID3v1 tag.

id3v1-samples.tar.gz

These are related issues for your information

https://github.com/lieff/minimp3/issues/57 https://github.com/lieff/minimp3/issues/66