SYNOPSIS

        #!perl -w
        use 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;

DESCRIPTION

The MP4::Info module can be used to extract tag and meta information from \s-1MPEG-4\s0 audio (\s-1AAC\s0) 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 \s-1MPEG-4\s0 files. \s-1OOP\s0 interface to the rest of the module. The same keys available via \*(C`get_mp4info\*(C' and \*(C`get_mp4tag\*(C' are available via the returned object (using upper case or lower case; but note that all-caps '\s-1VERSION\s0' will return the module version, not the \s-1MPEG-4\s0 version). Passing a value to one of the methods will not set the value for that tag in the \s-1MPEG-4\s0 file.

use_mp4_utf8([\s-1STATUS\s0])

Tells MP4::Info whether to assume that ambiguously encoded \s-1TAG\s0 info is \s-1UTF-8\s0 or Latin-1. 1 is \s-1UTF-8\s0, 0 is Latin-1. Default is \s-1UTF-8\s0. 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 \*(C`:utf8\*(C' or \*(C`:all\*(C' export tag.

get_mp4tag (\s-1FILE\s0)

Returns hash reference containing the tag information from the \s-1MP4\s0 file. The following keys may be defined: ALB Album APID Apple Store ID ART Artist CMT Comment COVR Album art (typically JPEG or PNG data) CPIL Compilation (boolean) CPRT Copyright statement DAY Year DISK Disk number & total (2 integers) GNRE Genre GRP Grouping NAM Title RTNG Rating (integer) TMPO Tempo (integer) TOO Encoder TRKN Track number & total (2 integers) WRT Author or composer For compatibility with MP3::Info, the \s-1MP3\s0 ID3v1-style keys \s-1TITLE\s0, \s-1ARTIST\s0, \s-1ALBUM\s0, \s-1YEAR\s0, \s-1COMMENT\s0, \s-1GENRE\s0 and \s-1TRACKNUM\s0 are defined as synonyms for \s-1NAM\s0, \s-1ART\s0, \s-1ALB\s0, \s-1DAY\s0, \s-1CMT\s0, \s-1GNRE\s0 and TRKN[0]. Any and all of these keys may be undefined if the corresponding information is missing from the \s-1MPEG-4\s0 file. On error, returns nothing and sets $@.

get_mp4info (\s-1FILE\s0)

Returns hash reference containing file information from the \s-1MPEG-4\s0 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 kHz SIZE bytes in audio stream

SECS total seconds, rounded to nearest second MM minutes SS leftover seconds MS leftover milliseconds, rounded to nearest millisecond TIME time in MM:SS, rounded to nearest second

COPYRIGHT boolean for audio is copyrighted ENCODING 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 audio ENCRYPTED boolean for audio data is encrypted Any and all of these keys may be undefined if the corresponding information is missing from the \s-1MPEG-4\s0 file. On error, returns nothing and sets $@.

BUGS

Doesn't support writing tag information to \s-1MPEG-4\s0 files.

If you find a bug, please send me a patch. If you cannot figure out why it does not work for you, please put the \s-1MP4\s0 file in a place where I can get it (preferably via \s-1FTP\s0, or \s-1HTTP\s0) and send me mail regarding where I can get the file, with a detailed description of the problem. I will keep a copy of the file only for as long as necessary to debug the problem.

AUTHOR

Jonathan Harris <[email protected]>.

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 \s-1PSP\s0 support.

RELATED TO MP4::Info…

MP4::Info Project Page

<http://search.cpan.org/~jhar/MP4-Info>

\s-1ISO\s0 14496-12:2004 - Coding of audio-visual objects - Part 12: \s-1ISO\s0 base media file format

<http://www.iso.ch/iso/en/ittf/PubliclyAvailableStandards/c038539_ISO_IEC_14496-12_2004(E).zip>

\s-1ISO\s0 14496-14:2003 - Coding of audio-visual objects - Part 14: \s-1MP4\s0 file format

<http://www.iso.org/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=38538> (Not worth buying - the interesting stuff is in Part 12).

3GPP \s-1TS\s0 26.244 - 3GPP file format (3GP)

<http://www.3gpp.org/ftp/Specs/html-info/26244.htm>

QuickTime File Format

<http://developer.apple.com/documentation/QuickTime/QTFF/>

\s-1ISO\s0 14496-1 Media Format

<http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt>

MP3::Info

<http://search.cpan.org/~cnandor/MP3-Info/>

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.