I've found an ID3 tag extraction library
(http://www.rabbitfarm.com/id3.html) for MP3 files, but I need libraries for
other filetypes.
Thanks,
Samir Sheldenkar
JMF
Thanks - but looking at the API and trying out small programs, I can't work
out how to actually use this API to extract the information I'm looking for.
Does anyone have experience of using JMF and could help me work out how to
just use it to get file information?
Samir
Yes, me.
:-)
Ask a more specific question, you'll get a more specific answer.
http://java.sun.com/products/java-media/jmf/index.html
Oooh. "Programmer's Guide"
http://java.sun.com/products/java-media/jmf/2.1.1/guide/
"Data Model"
http://java.sun.com/products/java-media/jmf/2.1.1/guide/JMFArchitecture.html#112436
The length you can get once the data item is in a player.
The next step is to follow those to get a DataSource and then see what
you can get from it. Also checked once a Player has a source ready.
Quicktime has it's own way of doing meta data. Windows files also.
Playing with things in Eclipse's debugger would probably be most helpful.
Oh, and for MP3, you might also check out
http://javamusictag.sourceforge.net/
OK, thanks. I'd looked at the programmer's guide and API documentation, but
am finding it difficult to extract just the information that is relevant for
my needs - most of the documentation is obviously geared towards uses where
the file needs to be played or processed in some fashion, and so it just
serves to confuse me.
Here's a small test program:
----------------------
import java.io.*;
import java.net.*;
import javax.media.*;
import javax.media.protocol.*;
import javax.media.bean.playerbean.*;
class Test {
public static void main(String[] args) throws Exception {
URL url = new File(args[0]).toURL();
MediaPlayer m = new MediaPlayer();
m.setMediaLocator(new MediaLocator(url));
URLDataSource ds = new URLDataSource(url);
System.out.println("Using player, duration is:
"+m.getDuration().getSeconds()+" seconds");
System.out.println("Using datasource, duration is:
"+ds.getDuration().getSeconds()+" seconds");
}
}
-------------------------------------
Both the player and datasource give a DURATION_UNKNOWN value.
I don't know if I'm using the player correctly - do realize() and/or
prefetch() need to be called? I've tried doing that and it seems to make no
difference. Also, the API documentation for URLDataSource.getDuration() says
"Returns Duration.DURATION_UNKNOWN. The duration is not available from an
InputStream." Why??
Once you have a DataSource, how would you extract metadata from it? There
don't seem to be any obvious methods or classes to do this...
Thanks for all your help,
Samir
It's been a while since I worked in it, so I'd have to take a little
time to look it up.
However, breakpointing in Eclipse will instantly let you see what you
have, and even the true classes, IIRC.
I just tried installing jmf and I get a bunch of problems. I've extracted
the files, and set the 2 env. variables. I try running the diagnostics
applet and only netscape 4 sorta works. (I hear sound but no video with the
sample pages). IE6 and Netscape 7 give me a grey box with a red x on the top
left. I just realized that netscape 7 doesn't want to run any java applets
at all and instead has made me reinstall the jre twice. Can somebody please
help me.
I'm also interested in reading metadata from audio/video files. If jmf does
not work for this task, I'd be willing to write a library for it (if I can
get information on how to do it). I think rtsp servers can be queried for
such information. Not sure about windows media stuff though. Not sure about
http/file real/quicktime stuff either.