How to detect media file type in Java?

L

lukspica

Hi, I have a little problem :) I have to process a lot of media files
and distinguish them by content to video files and audio only files.
These files can use virtually any codec/container available. Is there
any way to do such a thing in Java? I have made huge research on the
net looking for libraries for identifying media files, but I haven't
found anything useful :( I am begging you for help, I don't have any
idea how to solve this problem..

Regards :)
 
A

Andrew Thompson

Hi, I have a little problem :)

Huh! Famous last words!

But, how do you know you have a little
problem, until you discover the little
(easy, quick) solution?
..I have to process a lot of media files
and distinguish them by content to video files and audio only files.

..WAV, .MID, .AU ..are all audio. For
'pure audio' file types, you can simply
base the decision on the file extension.
These files can use virtually any codec/container available. Is there
any way to do such a thing in Java?

It is a computable problem, so I expect
the answer is 'yes, for any currently known,
and publicly defined, format'.
...I have made huge research on the
net looking for libraries for identifying media files, but I haven't
found anything useful ..

JMF can recognise a number of media types,
but for the video types (and codecs) that are
not supported by JMF, you will need to find
different solutions.

There are a number of other (Java based)
libraries out there that provide support
for other formats and codecs, but I doubt
they will extend the formats over and above
what the JMF can identify by much.

So that leaves (as far as I can see) writing
a Java class(es) that peeks into the head
and/or tail of the file of interest, looking
for markers of codecs and formats.
..:( I am begging you for help,

Begging around here is more likely to earn
contempt, than help. (I thought I'd cut
you a break, this one time.)
..I don't have any
idea how to solve this problem..

Have you considered hiring a format/codec
expert?

Andrew T.
 
R

Real Gagnon

Hi, I have a little problem :) I have to process a lot of media files
and distinguish them by content to video files and audio only files.
These files can use virtually any codec/container available. Is there
any way to do such a thing in Java? I have made huge research on the
net looking for libraries for identifying media files, but I haven't
found anything useful :( I am begging you for help, I don't have any
idea how to solve this problem..

See http://www.rgagnon.com/javadetails/java-0487.html

You have two possibles solutions : based on the file extension or a "magic
header" detection.

Bye.
 
L

lukspica

Thanks for your reply :) My post may sounded desperate - this is
because I ran out of ideas.. The main problem is that all files have
same extension :) Does this Magic library works with all common audio/
video formats? I need only to determine if file contains video data,
or it is audio only media. I don't need information about used codecs,
containers etc. Is it possible to achieve this by using JMF?
 
A

Andrew Thompson

On Mar 21, 10:43 pm, (e-mail address removed) wrote:
...
..Is it possible to achieve this by using JMF?

Sure, so long as 'all the formats' are
understood by JMF, else, no.

Andrew T.
 
O

Oliver Wong

Andrew Thompson said:
It is a computable problem, so I expect
the answer is 'yes, for any currently known,
and publicly defined, format'.

It's actually a bit trickier than that, as some formats "overlap".
More formally, there exists a sequence of bits which could represent a
legal instance of data in one video codec format, as well as a legal
instance of data in a different video codec format.

In practice, there are many heuristics that one can do (checking the
file extension is one of them, asking the user is another, computing the
hash of the media file and looking it up in some centralized database over
the internet is yet another), but in general, the problem is insoluble.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top