metadata-extractor icon indicating copy to clipboard operation
metadata-extractor copied to clipboard

Support ID3 for MP3 files

Open drewnoakes opened this issue 6 years ago • 8 comments

drewnoakes avatar Mar 19 '18 16:03 drewnoakes

MP3

JackChenzy avatar Mar 19 '18 16:03 JackChenzy

Basic support added in #337

Note: Many files will not be identified yet as a result of the ID3 block

payton avatar Apr 04 '18 20:04 payton

From @payton's discussion on #337:

File identification is based off of the first frame header in the file, which has this structure http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html

Issues

  • It is only guaranteed that the first 11 bits are set, so I only check that the file starts with 0xFF as the signature. One option is to add the remaining combinations (MPEG1 + Layer2, MPEG2 + Layer2, etc) to filetypedetector, but that would be cumbersome.
  • Some MPEG files use bitrate switching, which means the first frame bitrate is not necessarily the same for the rest of the file's frames.
  • MPEG 2.5 not yet supported

ID3 documentation can be found here: http://id3.org/Home

drewnoakes avatar Apr 07 '18 18:04 drewnoakes

Any example of how to use it for MP3 and ?MP4?

cinder92 avatar Jun 16 '18 07:06 cinder92

It will be helpful to look at the ISO/IEC TR 11172-5:1998 reference software, which is available at http://standards.iso.org/ittf/PubliclyAvailableStandards/

This is written in C, but has a lot of useful information.

payton avatar Oct 17 '18 17:10 payton

@payton

Note: Many files will not be identified yet as a result of the ID3 block

If the above still applies, I wrote some code for skipping ID3v2 in FLAC which you can modify and use if you want here: https://github.com/DigitalMediaServer/cuelib/blob/6146cd2c0948244d3bcc7132801491550b80decb/cuelib-core/src/main/java/org/digitalmediaserver/cuelib/io/FLACReader.java#L533-L554

The only thing you need to do is to identify the magic bytes and then use their special "32/28 bit synchsafe integer" calculation to find the length to skip.

This doesn't handle ID3v1 since the code in question is for parsing FLAC files, which don't support ID3v1, but I believe that is even simpler to handle.

Nadahar avatar Oct 17 '18 19:10 Nadahar

I'm not sure what implications the ISO license has on using their code as a reference.

https://www.iso.org/terms-conditions-licence-agreement.html#Customer-Licence

drewnoakes avatar Oct 17 '18 19:10 drewnoakes

Thank you, @Nadahar ! That would be very useful.

Fair point, @drewnoakes . It is listed as 'reference software', but I will look more into that before proceeding with any work related to this.

payton avatar Oct 17 '18 19:10 payton