my $video = Video::Info::MPEG->new( -file => $filename );
print $file->type; ## MPEG
## Audio information
print $file->acodec; ## MPEG Layer 1/2
print $file->acodecraw; ## 80
print $file->achans; ## 1
print $file->arate; ## 128000 (bits/sec)
print $file->astreams ## 1
## Video information
printf "%0.2f", $file->fps ## 29.97
print $file->height ## 240
print $file->width ## 352
print $file->vstreams ## 1
print $file->vcodec ## MPEG1
print $file->vframes ## 529
print $file->vrate ## 1000000 (bits/sec)
DESCRIPTIONThe Moving Picture Experts Group (MPEG) is a working group in charge of the development of standards for coded representation of digital audio and video.
MPEG audio and video clips are ubiquitous but using Perl to programmatically collect information about these bitstreams has to date been a kludge at best.
This module parses the raw bitstreams and extracts information from the packet headers. It supports Audio, Video, and System (multiplexed audio and video) packets so it can be used on nearly every MPEG you encounter.
METHODSVideo::Info::MPEG is a derived class of Video::Info, a factory module "designed to meet your multimedia needs for many types of files".
- new( -file => FILE )
- Constructor. Requires the -file argument and returns an Video::Info::MPEG object.
- Parses the bitstreams in the FILE provided to the constructor. Returns 1 on success or 0 if the FILE could not be parsed as a valid MPEG audio, video, or system stream.
INHERITED METHODSThese methods are inherited from Video::Info. While Video::Info may have changed since this documentation was written, they are provided here for convenience.
- Returns the type of file. This should always be MPEG.
- Returns the contents of the userdata MPEG extension. This often contains information about the encoder software.
- Returns the number of audio bitstreams in the file. Usually 0 or 1.
- Returns the audio codec
- Returns the hexadecimal audio codec.
- Returns the number of audio channels.
- Returns the audio rate in bits per second.
- Returns the number of video bitstreams in the file. Usually 0 or 1.
- Returns the floating point number of frames per second.
- Returns the number of vertical pixels (the video height).
- Returns the number of horizontal pixels (the video width).
- Returns the video codec (e.g. MPEG1 or MPEG2).
- Returns the number of video frames.
- Returns the video bitrate in bits per second.
EVIL DIRECT ACCESS TO CLASS DATASo you secretly desire to be the evil Spock, eh? Well rub your goatee and read on.
There are some MPEG-specific attributes that don't yet fit nicely into Video::Info. I am documenting them here for the sake of completeness.
Note that if you use these, you may have to make changes when new versions of this package are released. There will be elegant ways to access them in the future but we wanted to get this out there.
These apply to audio bitstreams:
- The MPEG version. e.g. 1, 2, or 2.5
- The MPEG layer. e.g. 1, 2, 3.
The audio mode. This is one of:
Mono Stereo Dual Channel Intensity stereo on bands 4-31/32 Intensity stereo on bands 8-31/32 Intensity stereo on bands 12-31/32 Intensity stereo on bands 16-31/32 Intensity stereo off, M/S stereo off Intensity stereo on, M/S stereo off Intensity stereo off, M/S stereo on Intensity stereo on, M/S stereo on
The audio emphasis, if any.
No Emphasis 50/15us Unknown CCITT J 17 Undefined
- The sampling rate (e.g. 22050, 44100, etc.)
The value of the protection bit. This is used to indicate copying
is prohibited but is different than copyright().
These apply to video:
The aspect ratio if the ratio falls into one of the defined standards.
Otherwise, it's Reserved.
Forbidden 1/1 (VGA) 4/3 (TV) 16/9 (Large TV) 2.21/1 (Cinema) Reserved
AUTHORSBenjamin R. Ginter, <email@example.com> Allen Day, <[email protected]>
Copyright (c) 2001-2002 Aladdin Free Public License (see LICENSE for details) Benjamin R. Ginter <firstname.lastname@example.org>, Allen Day <[email protected]>