How to detect media file type in Java?

Discussion in 'Java' started by lukspica@gmail.com, Mar 21, 2007.

  1. Guest

    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 :)
     
    , Mar 21, 2007
    #1
    1. Advertising

  2. On Mar 21, 11:17 am, 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.
     
    Andrew Thompson, Mar 21, 2007
    #2
    1. Advertising

  3. Real Gagnon Guest

    > 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.
    --
    Real Gagnon from Quebec, Canada
    * Java, Javascript, VBScript or PowerBuilder snippets
    * http://www.rgagnon.com/howto.html
    * http://www.rgagnon.com/bigindex.html
     
    Real Gagnon, Mar 21, 2007
    #3
  4. Guest

    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?
     
    , Mar 21, 2007
    #4
  5. On Mar 21, 10:43 pm, 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.
     
    Andrew Thompson, Mar 21, 2007
    #5
  6. Oliver Wong Guest

    "Andrew Thompson" <> wrote in message
    news:...
    >
    >> 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
     
    Oliver Wong, Mar 23, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oscar Thornell

    Detect version of media player

    Oscar Thornell, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    527
    Nicholas Paldino [.NET/C# MVP]
    Dec 2, 2003
  2. tom watson

    link css help re "type" media

    tom watson, Sep 16, 2003, in forum: HTML
    Replies:
    5
    Views:
    504
    Steve Pugh
    Sep 16, 2003
  3. Henri Sivonen
    Replies:
    0
    Views:
    413
    Henri Sivonen
    Apr 30, 2005
  4. Determine media type

    , Oct 3, 2005, in forum: Ruby
    Replies:
    4
    Views:
    106
Loading...

Share This Page