Okay, I've been working with a web-application that allows users to upload files. I'm using CGI.pm to do the actual uploading. The uploading part is going along nicely, but I need to extract some metadata from the uploaded files to be able to categorize them.

I use stat() and File::MimeInfo::Magic::mimetype to figure out the datatype of the file. But this module has problem figuring out that OpenDocument is in fact ODT and not application/zip. I guess I need to use the passed filename's extension to do a lookup in some table (if you know which one, please tell me!) and assume a specific mimetype if there is in fact an extension passed into the function (the filename is from CGI.pm uploadInfo() ).

For detecting image metadata I use Image::Size, but this ONLY detects dimensions, not other metadata like author and title.

In the sound department I use Audio::Wav and MP3::Info to detect information like duration and title. This works more or less as it should.

It's in the video department I have most problems. MS WMA is detected as video/x-ms-asf (using Audio::WMA), and is thus not filed as audio, but as video (even though it doesn't contain any video frames). The other problem is that I'm unable to extract video dimensions (width+height) out of WMV/ASF files. And because the openquicktime Perl module isn't adhering to my debug settings, I had to fork and use qtinfo (external command) to grab QuickTime metadata (which isn't very cross-platform). And for basic MPEG1/2/4 streams I don't know what to do. None of the packages I found on CPAN seems to be stable/mature enough to feed me sufficient information.

As you can see, this method brings with it a lot of dependencies, and makes it harder to install the application. I was hoping there was an easier way to detect all of the metadata. Maybe there is a metadata extraction project that has integration with Perl? I was thinking about FFmpeg's libavformat, but it's hard to find any documentation on how to use this library in Perl wrt. metadata extraction.

Solutions?

PS: Forking wouldn't be all that bad if there was one single application that could actually manage to detect everything I needed, but doing it for all the different checks would be overkill. Suggestions welcome in that department aswell.


In reply to Multimedia metadata extraction - how to have it all? by robins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.