Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

How to detect media file type in Java?

Thread view: 
lukspica@gmail.com - 21 Mar 2007 01:17 GMT
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 :)
Andrew Thompson - 21 Mar 2007 02:54 GMT
On Mar 21, 11:17 am, luksp...@gmail.com wrote:
> 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.
Oliver Wong - 23 Mar 2007 16:24 GMT
>> 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'.

   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
Real Gagnon - 21 Mar 2007 12:24 GMT
> 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.
[quoted text clipped - 3 lines]
> 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.
Signature

Real Gagnon  from  Quebec, Canada
* Java, Javascript, VBScript or PowerBuilder snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html

lukspica@gmail.com - 21 Mar 2007 12:43 GMT
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?
Andrew Thompson - 21 Mar 2007 13:26 GMT
On Mar 21, 10:43 pm, luksp...@gmail.com 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.