The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Audio::M4P::QuickTime -- Perl module for m4p/mp4/m4a Quicktime audio files

DESCRIPTION

In late 2004 an update to iTunes made that program incompatible with decrypted files still containing meta information identifying the content as having been purchased via iTMS. This forced an update to the module Audio::M4pDecrypt (now renamed Audio::M4P::Decrypt), which now strips such meta information from the file. As a happy side effect of these changes, this module, part of the Audio::M4P distribution, now allows extraction and modification of meta information in such files, similar to the MP3::Info and MP4::Info modules.

About QuickTime File Structure and Atoms

Quicktime (MP4) files are arranged as a stream of 'atoms', each containing a header consisting of size and type information followedby data. The data may contain other Quicktime atoms. iTMS (M4P) music files are Quicktime audio files which are encrypted using a combination of information in the file's drms atom and information which is commonly stored on the computer or audio player.

SYNOPSIS

     use Audio::M4P::QuickTime;
    
     my $mp4file = "file.m4p";
    
     my $qt = new Audio::M4P::QuickTime(file => $mp4file);
    
     my $tags = $qt->GetMetaInfo;
    
     print "Artist is $tags->{ARTIST}\n" if $tags->{ARTIST};

METHODS

new
 my $qt = Audio::M4P::QuickTime->new;

 $qt = new Audio::M4P::QuickTime(
   DEBUG => 2, 
   DEBUGDUMPFILE => 'quicktime_treedump.html'
 );

 $qt = new Audio::M4P::QuickTime(file => 'qt_audio_file.m4p');

Create a new Audio::M4P::QuickTime object. DEBUG => 1 as argument causes parse and other information to be printed to stdout during processing. DEBUG => 2, DEBUGDUNMPFILE => "file" causes an HTML tree representation of the QuickTime file to be emitted to the file given as value to the argument pair. file => "filename.m4p" causes the named QuickTime file to be read and parsed during object initialization.

ReadFile
 $qt->ReadFile("filename.m4a");

Read the named file into the QuickTime object buffer.

ParseBuffer
 $qt->ParseBufffer;

Parse the file that has been read as a QuickTime stream.

WriteFile
 $qt->WriteFile("ouput.m4p");

Write the (possibly modified) file back to the output file argument.

GetMetaInfo
 my $hashref = $qt->GetMetaInfo;
 while(my($tag, $value) = each %{$hashref}) { 
    print "$tage => $value\n";
 }

Returns a hash reference to meta tag information. Attempts to be compatible with tag information formats in MP3::Info and MP4::Info. Potential tags are AAID, ALBUM, ARTIST, COMMENT, COM, CPIL, CPRT, YEAR, DISK, GENRE, GRP, NAM, RTNG, TMPO, TOO, TRKN, and WRT. Note that, due to preservation of compatibility with MP3::Info by returning tag info as a hash reference, duplicate entries of the same tag name, such as multiple comment fields, will not be returned in the hash reference.

GetMP4Info
 my $hashref = $qt->GetMP4Info;
 while(my($tag, $value) = each %{$hashref}) { 
    print "$tage => $value\n";
 }

Returns a hash reference to MP3 tag audio information. Attempts to be compatible with tag information formats in MP3::Info and MP4::Info. Potential tags are LAYER (1), VERSION (4), SIZE, SECONDS, SS, MM, and BITRATE.

SetMetaInfo
 my $comment = "After paying for this music file, I have fair use rights to change it.";

 $qt->SetMetaInfo(COMMENT => $comment);
 $qt->SetMetaInfo(GENRE => "Bebop", 1, 'day');

Set a meta information field. The third argument, if given and true, indicates that the program should replace all instances of meta data of this type with the new entry, rather than adding the tag to the existing meta data. The fourth argument, if given and true, indicated a tag value before which the new tag is to be placed in the file.

BUGS

    There ought to be a DWIM way to set iTunes M4P compatible metadata without pack() gymnastics.

    No support in Atom.pm currently for resizing of single atoms over 4294967296 bytes (4.2 gigabytes) in size. This should only occur with large movie files, not with MP4 audio.

    The Audio::M4P::* code is not re-entrant, due to recursive changes to containers not being thread-safe. Threaded code using these modules may need to lock down all method calls with a semaphore or other serialization method.

AUTHOR

William Herrera wherrera@skylightview.com.

SUPPORT

Questions, feature requests and bug reports should go to <wherrera@skylightview.com>.

COPYRIGHT

    Copyright (c) 2003-2005 William Herrera. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.