Reading information about MP3's
Page 1 of 112 Replies - 2610 Views - Last Post: 09 June 2008 - 11:37 AM
#1
Reading information about MP3's
Posted 03 June 2008 - 01:26 PM
Replies To: Reading information about MP3's
#2
Re: Reading information about MP3's
Posted 03 June 2008 - 01:28 PM
Servant, on 3 Jun, 2008 - 01:26 PM, said:
Do you have the Info or you really want to extract it from the MP3 file ?
If you have the info it can be easy.
Show us the piece of code where you read the .mp3 file
This post has been edited by pbl: 03 June 2008 - 01:30 PM
#3
Re: Reading information about MP3's
Posted 03 June 2008 - 01:58 PM
{
File musiek = new File (naam);
File alfa[] = musiek.listFiles ();
for (int z = 0 ; z < alfa.length ; z++)
{
if (alfa [z].isFile ())
{
Files.add (alfa [z]);
// System.out.println (Files.lastElement ());
}
else if (alfa [z].isDirectory ())
{
FileSoek zxc = new FileSoek (alfa [z].toString ());
//System.out.println (alfa [z].toString ());
} //
}
}
this is where i get my directrys from. you see that i cant take the simple rout
#4
Re: Reading information about MP3's
Posted 03 June 2008 - 05:08 PM
import java.io.*;
public class Mp3 {
public static void main(String[] args) {
try {
File song = new File(args[0]);
FileInputStream file = new FileInputStream(song);
int size = (int)song.length();
file.skip(size - 128);
byte[] last128 = new byte[128];
file.read(last128);
String id3 = new String(last128);
String tag = id3.substring(0, 3);
if (tag.equals("TAG")) {
System.out.println("Title: " + id3.substring(3, 32));
System.out.println("Artist: " + id3.substring(33, 62));
System.out.println("Album: " + id3.substring(63, 91));
System.out.println("Year: " + id3.substring(93, 97));
} else
System.out.println(args[0] + " does not contain"
+ " ID3 info.");
file.close();
} catch (Exception e) {
System.out.println("Error — " + e.toString());
}
}
}
This post has been edited by cutegrrl: 03 June 2008 - 05:08 PM
#5
Re: Reading information about MP3's
Posted 04 June 2008 - 02:04 AM
#6
Re: Reading information about MP3's
Posted 04 June 2008 - 10:06 AM
Servant, on 4 Jun, 2008 - 02:04 AM, said:
The size you got minus 128 may give you a good approximation
int size = (int)song.length();
I don't know if there is a strict relation between number of bytes and number of seconds
#7
Re: Reading information about MP3's
Posted 04 June 2008 - 10:30 AM
#8
Re: Reading information about MP3's
Posted 04 June 2008 - 12:46 PM
#10
Re: Reading information about MP3's
Posted 05 June 2008 - 04:03 AM
1lacca, on 4 Jun, 2008 - 12:50 PM, said:
ok, I checked. The problem is I now dont know how to extract the bitrate from the mp3. not only that, but I learned that the previous anser (ID3 TAG) will only give me the information on a third of my mp3's. seems the new mp3's have a tag in the beginning, but I cant seem to find it. :'(
Any other idea's?
#11
Re: Reading information about MP3's
Posted 05 June 2008 - 04:15 AM
Servant, on 5 Jun, 2008 - 01:03 PM, said:
Then read it again, it is there. It is not about ID3 tag, it is about the MP3 itself, so it will work with VBRs as well (but you'll have to read through the whole file)
Servant, on 5 Jun, 2008 - 01:03 PM, said:
There are two formats, ID3v2 is also used.
Other than that, if an mp3 is not tagged, then you won't be able to extract the title of the song. Some program use some heuristic in this case, and try to parse the filename with different strategies, or simply display it without the extension.
#12
Re: Reading information about MP3's
Posted 05 June 2008 - 08:15 AM
ID3v2, in comparison, is dreadfully complex. There are known fields, and user fields, no fixed sizes, unicode... great fun. You'd honestly be better off looking at one of the many public implementations first. Try here: http://www.id3.org/Implementations
If you do an ID3v2 dump of a file you can find all kinds of interesting stuff. Lots of MP3 players throw their own references into the things. Also, many players are in the habit of double tagging, with both versions logged on the file at the same time. It's not uncommon to see files with tagging cruft at the end because various programs didn't play nice with what was already there.
#13
Re: Reading information about MP3's
Posted 09 June 2008 - 11:37 AM
|
|

New Topic/Question
Reply




MultiQuote





|