Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Mp4 support now added to opensrc jaudiotagger library (Read 7578 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Mp4 support now added to opensrc jaudiotagger library

A first cut of Mp4 metadata support is now added to jaudiotagger Java library. I think this is the only open source Java library that reads and writes mp4 and m4a metadata (itunes  format) its released under LGPL with code examples at
http://www.jthink.net/jaudiotagger/examples.jsp. It supports Reverse Dns Field and Multiple Cover Art in addition to the standard metadata fields.

It is working fine for my test cases, but there are some areas Im currently stumped on, if anybody could help me out with any of the following that would be great.

1. How do you properly calculate bitrate?
2. How do you calculate number of channels/Stereo ?
3. Most Fields with Byte type use a single byte (such as cpil and pgap) but tmpo requires two bytes, are there any other byte fields that require multiple bytes.
4.Are there any other binary fields except for the artwork (covr) field
5.How do you set the rtng field
6.In iTunes even if if select a genre from the list it still uses custom genre field (@gen) rather than the genr
field, how do I get it to use genr or ist now defunct.
7. What applications write mp4s with ID3v2 data instead.
8. When modificiations are made to a file my algorithm is as follows
if(total size of metadata under ilst atom ==original size)
(
      replace data under ilst atom     
)
else if(total size of metadata under ilst atom <original size)
(
      replace data under ilst atom
      modify size of ilst atom to match size of its metadata
      increase size of free atom so meta atom is same size as before
)
else if(total size of metadata under ilst atom >original size)
(
      if(total additional size required < (space in free atom - free atom header size))
      (
              replace data under ilst atom
              modify size of ilst atom to match size of its metadata
              decrease size of free atom so meta atom is same size as before
      )
      else
      (
              extra size = (additional size required - size of free atom)
              replace data under ilst atom
              modify size of ilst atom to match size of its metadata
              dont write free atom
              modify size field of meta, udta and moov atom adding extra size             
      )
)
So even in the last case i never have to chnage any data except the metadata itself and the sizes of its parent and the fiel plays , is this enough or is there anything else that has to be done.

thanks Paul

Mp4 support now added to opensrc jaudiotagger library

Reply #1
2. How do you calculate number of channels/Stereo ?

In the spirit of information sharing did this with by searching for
MOOV.TRAK.MDIA.MINF.STBL.STSD.MP4A
and finding it within the MP4A atom (bytes 16,17)

Mp4 support now added to opensrc jaudiotagger library

Reply #2

2. How do you calculate number of channels/Stereo ?

In the spirit of information sharing did this with by searching for
MOOV.TRAK.MDIA.MINF.STBL.STSD.MP4A
and finding it within the MP4A atom (bytes 16,17)

You should not expect that that value always has valid information (it's even defined differently between different subparts of the mpeg-4 standard). To have a better idea you should decode the audio specific config.

Mp4 support now added to opensrc jaudiotagger library

Reply #3
You should not expect that that value always has valid information (it's even defined differently between different subparts of the mpeg-4 standard). To have a better idea you should decode the audio specific config.

Im only dealing the with the case of a file containing a single audio track (AAC encoded), in that case doesnt it always have this MP4A atom, which atom is the audio specific config ?

Mp4 support now added to opensrc jaudiotagger library

Reply #4

You should not expect that that value always has valid information (it's even defined differently between different subparts of the mpeg-4 standard). To have a better idea you should decode the audio specific config.

Im only dealing the with the case of a file containing a single audio track (AAC encoded), in that case doesnt it always have this MP4A atom, which atom is the audio specific config ?


Yes, when there's an AAC track there should be a mp4a atom, but I mean that the "channels" value is not always the actual amount of channels (usually just 2 gets written there). The audioSpecificConfig is somewhere in the ESDS part.

Mp4 support now added to opensrc jaudiotagger library

Reply #5
Yes, when there's an AAC track there should be a mp4a atom, but I mean that the "channels" value is not always the actual amount of channels (usually just 2 gets written there). The audioSpecificConfig is somewhere in the ESDS part.

Your'e right, I have just found a file file shown as Mono in iTunes but recording 2 in the channels value. havent managed to work out the ESDS part yet.

Mp4 support now added to opensrc jaudiotagger library

Reply #6
Ok thanks, fixed found no of channels  in section 5 of esds atom (Also got bit rate from section 4 of esds atom)

 

Mp4 support now added to opensrc jaudiotagger library

Reply #7
Ive resolved the problems above, and posted a release at:
here
try out at your leisure.