MP4::Info3pm
Fetch info from mpeg-4 files (.mp4, .m4a, .m4p, .3gp)
Usage
#!perl -wuse MP4::Info;my $file = 'Pearls_Before_Swine.m4a';my $tag = get_mp4tag($file) or die "No TAG info";printf "$file is a %s track\n", $tag->{GENRE};my $info = get_mp4info($file);printf "$file length is %d:%d\n", $info->{MM}, $info->{SS};my $mp4 = new MP4::Info $file;printf "$file length is %s, title is %s\n",$mp4->time, $mp4->title;
Overview
The MP4::Info module can be used to extract tag and meta information from MPEG-4 audio (AAC) and video files. It is designed as a drop-in replacement for MP3::Info.
Note that this module does not allow you to update the information in MPEG-4 files.
- $mp4 = MP4::Info->new(FILE)
-
OOP interface to the rest of the module. The same keys available via
"get_mp4info"and"get_mp4tag"are available via the returned object (using upper case or lower case; but note that all-caps 'VERSION' will return the module version, not the MPEG-4 version).Passing a value to one of the methods will
notset the value for that tag in the MPEG-4 file.
- use_mp4_utf8([STATUS])
-
Tells MP4::Info whether to assume that ambiguously encoded TAG info is UTF-8 or Latin-1. 1 is UTF-8, 0 is Latin-1. Default is UTF-8.
Function returns new status (1/0). If no argument is supplied, or an unaccepted argument is supplied, function merely returns existing status.
This function is not exported by default, but may be exported with the
":utf8"or":all"export tag.
- get_mp4tag (FILE)
-
Returns hash reference containing the tag information from the MP4 file. The following keys may be defined:
ALB AlbumAPID Apple Store IDART ArtistCMT CommentCOVR Album art (typically JPEG or PNG data)CPIL Compilation (boolean)CPRT Copyright statementDAY YearDISK Disk number & total (2 integers)GNRE GenreGRP GroupingNAM TitleRTNG Rating (integer)TMPO Tempo (integer)TOO EncoderTRKN Track number & total (2 integers)WRT Author or composerFor compatibility with MP3::Info, the MP3 ID3v1-style keys TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE and TRACKNUM are defined as synonyms for NAM, ART, ALB, DAY, CMT, GNRE and TRKN[0].
Any and all of these keys may be undefined if the corresponding information is missing from the MPEG-4 file.
On error, returns nothing and sets
$@.
- get_mp4info (FILE)
-
Returns hash reference containing file information from the MPEG-4 file. The following keys may be defined:
VERSION MPEG version (=4)LAYER MPEG layer description (=1 for compatibility with MP3::Info)BITRATE bitrate in kbps (average for VBR files)FREQUENCY frequency in kHzSIZE bytes in audio streamSECS total seconds, rounded to nearest secondMM minutesSS leftover secondsMS leftover milliseconds, rounded to nearest millisecondTIME time in MM:SS, rounded to nearest secondCOPYRIGHT boolean for audio is copyrightedENCODING audio codec name. Possible values include:'mp4a' - AAC, aacPlus'alac' - Apple lossless'drms' - Apple encrypted AAC'samr' - 3GPP narrow-band AMR'sawb' - 3GPP wide-band AMR'enca' - Unspecified encrypted audioENCRYPTED boolean for audio data is encryptedAny and all of these keys may be undefined if the corresponding information is missing from the MPEG-4 file.
On error, returns nothing and sets
$@.
Thanks
Chris Nandor <[email protected]> for writing MP3::Info
Dan Sully at Slim Devices for cover art and iTunes/aacgain metadata patches.
Ruben Laguna for PSP support.
COPYRIGHT and LICENSE
Copyright (c) 2004-2010, Jonathan Harris <[email protected]>
This program is free software; you can redistribute it and/or modify it under the the same terms as Perl itself.
Releases
10 releases since Debian 4.0 (Etch); the text changed 5 times.