Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ID3 genre tag

Name: Anonymous 2010-08-30 18:13

http://en.wikipedia.org/wiki/ID3

First, I don't want to use existing libraries because all I need to extract is the genre.

What's the best way to extract the genre on a mp3 file?
I got mine working by reading chunks of bytes until it found the string "TCON".
The problem is when there is no genre tag ("TCON"). It scans the whole mp3 file and will take a lot of time.
Another is when there is a picture embedded on the file, how can I skip it?
Also, i'm planning to use this on a mobile phone so speed really does matter.

Name: Anonymous 2010-08-30 18:16

Have you tried reading the article you linked to?

Name: Anonymous 2010-08-30 18:19

>>2
yes

Name: Anonymous 2010-08-30 18:26

>>3
try reading it again

Name: Anonymous 2010-08-30 18:34

>>4
I really don't get what you want me to understand more there.

Name: Anonymous 2010-08-30 18:44

you only need to read the first 256 MiB

and, really, how slow is grep, even on a mobile phone?

Name: Anonymous 2010-08-30 18:52

>>6
oh. but most mp3 files are just below 10MB in size, so i really didn't put much attention in that.
also, i'm not sure if there's a grep in android. can't seem to find any. or am i just too dumb to look?

Name: Anonymous 2010-08-30 18:59

>>7
$ adb shell which grep
/system/xbin/grep

Name: Anonymous 2010-08-30 20:03

You don't need to read the entire file. Use a fucking library or look at how they do it.

Name: Anonymous 2010-08-30 20:31

>>1,9
...use a library ...
for this?

Name: Anonymous 2010-08-30 20:47

>>10
Yes. An ID3 library should be pretty small, and will almost certainly work better than whatever shitty hack you could come up with.

Name: Anonymous 2010-08-30 21:02

>>10
What exactly do you think libraries are for?

Name: Anonymous 2010-08-31 0:42

>>1
It scans the whole mp3 file
Why don't you stop at the end of the tag?

when there is a picture embedded on the file, how can I skip it?
By not scanning it.

Name: Anonymous 2010-08-31 1:45

ID3V1 is 128 bytes and comes at the end of the file, ID3V2 is variable size and comes at the beginning of the file.  Just check for both and use ID3V2 if present, ID3V1 if not, or abort if neither exist.  Scanning the entire file is never necessary.  But yes, the non-stupid way to do it is to use a library, because the library would know where to look for the tags.

Name: Anonymous 2010-08-31 2:00

Just check for both and use ID3V2 if present, ID3V1 if not, or abort if neither exist.
Why would you check for both when ID3V2 is present? Wouldn't make sense to only check for ID3V1 when ID3V2 isn't present?

Name: Anonymous 2010-08-31 3:01

Scanning the entire file is never necessary.
Oh how I wish that were true. Too many of my files have data inserted throughout the stream. My media player doesn't like it either.

Name: Anonymous 2010-08-31 5:30

>>12
What exactly do you think libraries are for?
Uninstalling or recompiling with -O3 -malicious-double -ffast-math and lots of --disable-* and --without-* configure flags.

Name: Anonymous 2010-08-31 7:30

>>16
Then you have broken files.  You don't special-case an MP3 decoder to play the broken files that you happen to have in your collection.  If your goal really is to salvage this garbage, then what you are writing is some sort of "MP3 repair tool," which is far different from what you started out describing.

Don't change these.
Name: Email:
Entire Thread Thread List