Subscribed unsubscribe Subscribe Subscribe

#!/usr/bin/env perl

use strict;
use warnings;

use Audio::M4P::QuickTime;
use Getopt::Long;
use Pod::Usage;

GetOptions(
    \my %options,
    qw/input=s output=s help/,
);

pod2usage(0) if $options{help};
pod2usage(-1) unless $options{input} && $options{output};

my $qt = Audio::M4P::QuickTime->new( file => $options{input} );
my $moov = $qt->FindAtom("moov") or die "not found moov atom";
my @child_nodes = $moov->node->getAllChildren;
my ($meta_node) = grep { $_->getNodeValue->type eq "meta" } @child_nodes;

die "not found moov.meta atom" unless $meta_node;

my $moov_meta_node = $meta_node->getNodeValue;
my $size = $moov_meta_node->size;
my $pos  = $moov_meta_node->start;
$meta_node->getNodeValue->selfDelete;
$qt->FixStco( $size, $pos );
$qt->WriteFile($options{output});

__END__
=head1 NAME

remove-mora-tag.pl - remove moov.meta atom from m4a file

=head1 SYNOPSIS                 
                           
remove-mora-tag.pl --input <input file> --output <output file>

【コラム】新・OS X ハッキング! (67) DRMフリーで320kbps! 「Mora」の曲をiPhoneで聴こう | パソコン | マイナビニュース