Info::MPEG(3pm)

πŸ“¦
version 0.993 Β· 2 versions
  • 0.993 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.993 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Info::MPEG(3pm) β€” like, the whole vibe πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about the Info::MPEG(3pm) page from the User Contributed Perl Documentation. it's giving multimedia nerd and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

Video::Info::MPEG β€” a basic MPEG bitstream attribute parser. no cap, that's the whole job description. πŸ’…


🌸 SYNOPSIS 🌸

here's the little taste test, exactly as written:

use strict;
use Video::Info::MPEG;

my $video = Video::Info::MPEG->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)

(not me noticing astreams and friends don't have semicolons in the original β€” copy-paste it exactly as-is, bestie, i'm just the messenger 🫢)


πŸ¦‹ DESCRIPTION πŸ¦‹

so the Moving Picture Experts Group (MPEG) is a working group whose whole thing is developing standards for the coded representation of digital audio and video. iconic of them.

MPEG audio and video clips are literally everywhere, but using Perl to programmatically collect information about these bitstreams? up until now that's been a kludge at best. πŸ’€

this module parses the raw bitstreams and pulls information straight out of the packet headers. it supports Audio, Video, and System packets (that's multiplexed audio + video, iykyk), so it works on nearly every MPEG you encounter. main character module energy, fr fr. πŸ‘‘


πŸ’… METHODS πŸ’…

Video::Info::MPEG is a derived class of Video::Info, which is a factory module "designed to meet your multimedia needs for many types of files". (their words, and honestly? valid.)

  • new( -file => FILE ) β€” the constructor. it requires the -file argument and hands you back a Video::Info::MPEG object. no file, no object, periodt.
  • probe() β€” parses the bitstreams in the FILE you gave the constructor. returns 1 on success, or 0 if the FILE couldn't be parsed as a valid MPEG audio, video, or system stream. that's the whole vibe check right there. ✨

🌈 INHERITED METHODS 🌈

these methods come from Video::Info. heads up: Video::Info may have changed since this documentation was written, but they're listed here anyway, 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 info about the encoder software. detective work, slay.

πŸŽ€ 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, bestie. πŸ––

there are some MPEG-specific attributes that don't yet fit nicely into Video::Info. they're documented here for the sake of completeness.

⚠️ real talk: 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 they wanted to get this out there. you've been warned. πŸ’€

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 it's different than copyright(). sneaky little bit. πŸ™ˆ

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

πŸ‘‘ AUTHORS πŸ‘‘

Benjamin R. Ginter, <bginter@asicommunications.com> β€” Allen Day, <allenday@ucla.edu>


 Copyright (c) 2001-2002
 Aladdin Free Public License (see LICENSE for details)
 Benjamin R. Ginter <bginter@asicommunications.com>, Allen Day <allenday@ucla.edu>

πŸ”₯ SEE ALSO πŸ”₯

Video::Info Β· Video::Info::RIFF Β· Video::Info::ASF


and that's the whole page, bestie!! 🫢 this was perl v5.36.0, dated 2022-12-12, and you just read Info::MPEG(3pm) in full. go parse some bitstreams, you absolute icon. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from