I'm trying to organized music for a radio station and have an iTunes library with a huge number of music files. The files are in various formats (Flac, MP3, AAC, etc.). I need to break all the files up by format.
I have a simple Ruby script that walks the directory tree and can pull by extension, so I can move all .mp3 files into an MP3 directory. However, I have a problem with m4a files, because some .m4a files are Apple Lossless format and some are Apple's AAC format.
The problem I have is that the MP4Info gem seems only to have "Encoder," which returns something like iTunes 9.0.2, which is not helpful in determining lossless vs lossy formatting.
So, my thought is to take the SIZE attribute of the file and divide that by the SECS attribute. It seems that I should be able to come up with a decent rubric for bytes/second in a lossless vs a lossy format, since they will be roughly an order of magnitude off. I'm not sure what order of magnitude I'm looking for (it depends on bitrate, I'd guess).
Are there better, easier ways to do this?
So, it looks like using the heuristics for bitrate (e.g. the values given at en.wikipedia.org/wiki/Bit_rate#Audio_.28MP3.29) is useful, but maybe more useful is the iTunes list of songs.
It turns out that there is a column available in iTunes for bitrate- and anything saves as AAC will be listed as a bitrate of "256 (Variable)." So one can easily sort the entire music library by bitrate and find all songs with a value of 256. You could also see which are lower- and then anything above around 600 is going to be Lossless.
There's an issue around 300-500 or so. Depending on the complexity of the music, you might have a song with a bitrate of 400 or 500 that is lossless. Not sure what to do around there- but it's pretty minimum in total song number.