Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

MPEG::Info
Basic MPEG bitstream attribute parser.

MPEG::Info - Basic MPEG bitstream attribute parser.


NAME

MPEG::Info - Basic MPEG bitstream attribute parser.


SYNOPSIS


  use strict;

  use MPEG::Info;

  my $video = MPEG::Info->new( -file => $filename );

  $video->probe();

  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)


DESCRIPTION

The 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.


METHODS

MPEG::Info 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 MPEG::Info object.

probe()
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 METHODS

These methods are inherited from Video::Info. While Video::Info may have changed since this documentation was written, they are provided here for convenience.

type()
Returns the type of file. This should always be MPEG.

comments()
Returns the contents of the userdata MPEG extension. This often contains information about the encoder software.

Audio Methods

astreams()
Returns the number of audio bitstreams in the file. Usually 0 or 1.

acodec()
Returns the audio codec

acodecraw()
Returns the hexadecimal audio codec.

achans()
Returns the number of audio channels.

arate()
Returns the audio rate in bits per second.

Video Methods

vstreams()
Returns the number of video bitstreams in the file. Usually 0 or 1.

fps()
Returns the floating point number of frames per second.

height()
Returns the number of vertical pixels (the video height).

width()
Returns the number of horizontal pixels (the video width).

vcodec()
Returns the video codec (e.g. MPEG1 or MPEG2).

vframes()
Returns the number of video frames.

vrate()
Returns the video bitrate in bits per second.


EVIL DIRECT ACCESS TO CLASS DATA

So 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:

version
The MPEG version. e.g. 1, 2, or 2.5

layer
The MPEG layer. e.g. 1, 2, 3.

mode
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

emphasis
The audio emphasis, if any.

  No Emphasis

  50/15us

  Unknown

  CCITT J 17

  Undefined

sampling
The sampling rate (e.g. 22050, 44100, etc.)

protect
The value of the protection bit. This is used to indicate copying is prohibited but is different than copyright().

These apply to video:

aspect
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


EXPORT

None.


AUTHORS

Benjamin R. Ginter, <bginter@asicommunications.com>

Allen Day, <allenday@ucla.edu>


COPYRIGHT

Copyright (c) 2001-2002 Benjamin R. Ginter, Allen Day


LICENSE

QPL 1.0 (``free for non-commercial use'')


SEE ALSO

Video::Info RIFF::Info ASF::Info

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy