Click here to get back home

Multimedia file stats in Perl?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Multimedia file stats in Perl? Ilya Zakharevich 11-06-2006
Posted by Ilya Zakharevich on November 6, 2006, 7:09 pm
Please log in for more thread options


Each day the MP3::Tag module I maintain *looks* more and more like a
module to deal with arbitrary multimedia types... At least a lot of APIs
make sense for many other multimedia types; and the scripts supplied
with the module work mostly via these API.

But to actually address this similarity, I need (as a minimum) a way
to inspect a multimedia file, and get some stats about it.

The stats which come to my mind are

a) does it contain audio, video, stills, slideshows (or combinations
thereof)?

b) What is the duration, number of frames, framerate, size of (the
first?) image frame?

c) which module to use to get the embedded metadata?

d) what is the imbedded metadata?

Are there ready-to-use Perl solutions to these problems?

Thanks,
Ilya

P.S. The other (meta)questions is: which questions does it make sense
to ask about a given multimedia file if you do not care what is
the "format" of the file. This metaquestion should definitely
have been addressed by any multimedia architecture which
delegates the actual work to installable multimedia codecs.

Anyone knowing about this?


Posted by Ted Zlatanov on November 7, 2006, 11:58 am
Please log in for more thread options


On 7 Nov 2006, nospam-abuse@ilyaz.org wrote:

> Each day the MP3::Tag module I maintain *looks* more and more like a
> module to deal with arbitrary multimedia types... At least a lot of APIs
> make sense for many other multimedia types; and the scripts supplied
> with the module work mostly via these API.
>
> But to actually address this similarity, I need (as a minimum) a way
> to inspect a multimedia file, and get some stats about it.
>
> The stats which come to my mind are
>
> a) does it contain audio, video, stills, slideshows (or combinations
> thereof)?
>
> b) What is the duration, number of frames, framerate, size of (the
> first?) image frame?
>
> c) which module to use to get the embedded metadata?
>
> d) what is the imbedded metadata?
>
> Are there ready-to-use Perl solutions to these problems?
>
> Thanks,
> Ilya
>
> P.S. The other (meta)questions is: which questions does it make sense
> to ask about a given multimedia file if you do not care what is
> the "format" of the file. This metaquestion should definitely
> have been addressed by any multimedia architecture which
> delegates the actual work to installable multimedia codecs.
>
> Anyone knowing about this?

I've seen this solved with mplayer, which can just report information
about the file. I think this is worth consideration, even though it's
not pure Perl, because:

1) users may install codecs for mplayer in the future, why not use
them?

2) it's not hard to install mplayer

So maybe the module could provide an mplayer-driven investigation into
the file, in addition to the pure Perl approach.

I don't know about the metadata design, sorry. Maybe ID3v2 already is
sufficient, or there's something similar for video? I think there are
so many video codecs that there's just no unifying tag format yet.

Ted

Posted by Ilya Zakharevich on November 7, 2006, 11:33 pm
Please log in for more thread options


[A complimentary Cc of this posting was sent to
Ted Zlatanov
> I've seen this solved with mplayer, which can just report information
> about the file. I think this is worth consideration, even though it's
> not pure Perl, because:
>
> 1) users may install codecs for mplayer in the future, why not use
> them?

Since most users won't install mplayer, why bother?

> 2) it's not hard to install mplayer

Correct. However (in my experience), after installation, there is
little chance that it will work correct...

[In part, THIS THREAD is partially due to my bad experience with
mplayer. ;-) :-[]

> So maybe the module could provide an mplayer-driven investigation into
> the file, in addition to the pure Perl approach.

"In addition" is very fine with me. But I would prefer to have "pure
Perl approach" first. ;-)

Unfortunately, I have no idea where to start... I would prefer to
reuse existing modules than to write everything myself...

> I don't know about the metadata design, sorry. Maybe ID3v2 already is
> sufficient, or there's something similar for video?

There must be something like this for Matreoshka; additionally, OGG
has some (brain-dead) metadata storage...

> I think there are so many video codecs that there's just no unifying
> tag format yet.

My current approach is make MP3::Tag to look into file name_of_mm.id3
if it is asked to find metadata in name_of_mm.foo, and it could not
find it there. This will "solve" the problem with formats which do
not have metadata slots. However, it would be nice to have formats
WITH metadata slots accessible too - preferebly via type-transparent
interface.

Thanks,
Ilya

Posted by Ted Zlatanov on November 10, 2006, 12:01 pm
Please log in for more thread options


On 8 Nov 2006, nospam-abuse@ilyaz.org wrote:

>> I've seen this solved with mplayer, which can just report information
>> about the file. I think this is worth consideration, even though it's
>> not pure Perl, because:
>>
>> 1) users may install codecs for mplayer in the future, why not use
>> them?
>
> Since most users won't install mplayer, why bother?

They will probably install some movie player. Maybe we should use
Xine, VLC, etc. if they are available (and those players themselves
may use portable libraries that do what you want).

>> 2) it's not hard to install mplayer
>
> Correct. However (in my experience), after installation, there is
> little chance that it will work correct...
>
> [In part, THIS THREAD is partially due to my bad experience with
> mplayer. ;-) :-[]

OK. I don't share your experience but sure, not everyone is happy
with any given package.

>> So maybe the module could provide an mplayer-driven investigation into
>> the file, in addition to the pure Perl approach.
>
> "In addition" is very fine with me. But I would prefer to have "pure
> Perl approach" first. ;-)
>
> Unfortunately, I have no idea where to start... I would prefer to
> reuse existing modules than to write everything myself...

I think something portable must already exist. See above about
existing players.

>> I don't know about the metadata design, sorry. Maybe ID3v2 already is
>> sufficient, or there's something similar for video?
>
> There must be something like this for Matreoshka; additionally, OGG
> has some (brain-dead) metadata storage...

I don't know of Matroshka metadata. It's not a lovely format in any
case, but very popular nevertheless.

>> I think there are so many video codecs that there's just no unifying
>> tag format yet.
>
> My current approach is make MP3::Tag to look into file name_of_mm.id3
> if it is asked to find metadata in name_of_mm.foo, and it could not
> find it there. This will "solve" the problem with formats which do
> not have metadata slots. However, it would be nice to have formats
> WITH metadata slots accessible too - preferebly via type-transparent
> interface.

OK, so does anyone know for sure about:

- Matroshka
- WMV
- VOB

metadata? I am not an expert on any of them.

Ted

Posted by Ilya Zakharevich on November 10, 2006, 11:59 pm
Please log in for more thread options


[A complimentary Cc of this posting was sent to
Ted Zlatanov
> >> 1) users may install codecs for mplayer in the future, why not use
> >> them?
> >
> > Since most users won't install mplayer, why bother?
>
> They will probably install some movie player.

Why would they? Most computers have a player already installed for
them, and AFAI suspect, most do not allow querying from outside...

Thanks,
Ilya

Similar ThreadsPosted
How to include a connection file in perl December 2, 2006, 3:11 pm
I want an perl module for conver large html page file to multi little pages November 14, 2004, 3:02 am
install HTML::Template - Problem reading cache file / Bad file number July 24, 2004, 7:55 pm
Reading contents of an excel file from a test file May 15, 2007, 2:49 am
A do-file location: how the code inside that do-file find it? January 20, 2008, 12:32 am
DBD:mysql doesn't read mysql option file /etc/my.cnf file January 27, 2005, 11:19 pm
Win32::File August 29, 2004, 9:08 pm
SGI::FAM and File::PathConvert June 14, 2005, 10:58 am
file upload January 5, 2006, 7:00 am
How to read an IFO file ? February 25, 2006, 3:12 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap