Image-ExifTool
view release on metacpan or search on metacpan
lib/Image/ExifTool/MXF.pm view on Meta::CPAN
'060e2b34.0253.0101.0d010401.01170800' => { Name => 'CueWords', %localSet },
'060e2b34.0253.0101.0d010401.01180100' => { Name => 'Participant', %localSet },
'060e2b34.0253.0101.0d010401.01190100' => { Name => 'ContactsList', %localSet },
'060e2b34.0253.0101.0d010401.011a0200' => { Name => 'Person', %localSet },
'060e2b34.0253.0101.0d010401.011a0300' => { Name => 'Organisation', %localSet },
'060e2b34.0253.0101.0d010401.011a0400' => { Name => 'Location', %localSet },
'060e2b34.0253.0101.0d010401.011b0100' => { Name => 'Address', %localSet },
'060e2b34.0253.0101.0d010401.011b0200' => { Name => 'Communications', %localSet },
'060e2b34.0253.0101.0d010401.011c0100' => { Name => 'Contract', %localSet },
'060e2b34.0253.0101.0d010401.011c0200' => { Name => 'Rights', %localSet },
'060e2b34.0253.0101.0d010401.011d0100' => { Name => 'PictureFormat', %localSet },
'060e2b34.0253.0101.0d010401.011e0100' => { Name => 'DeviceParameters', %localSet },
'060e2b34.0253.0101.0d010401.011f0100' => { Name => 'NameValue', %localSet },
'060e2b34.0253.0101.0d010401.01200100' => { Name => 'Processing', %localSet },
'060e2b34.0253.0101.0d010401.01200200' => { Name => 'Projects', %localSet },
'060e2b34.0253.0101.0d010401.02010000' => { Name => 'CryptographicFramework', %localSet },
'060e2b34.0253.0101.0d010401.02020000' => { Name => 'CryptographicContext', %localSet },
'060e2b34.0253.0101.7f000000.00000000' => { Name => 'DefaultObject', Unknown => 1 },
'060e2b34.0401.0107.02090201.01000000' => { Name => 'CipherAlgorithmAES128CBC', Type => 'Label', Unknown => 1 },
'060e2b34.0401.0107.02090202.01000000' => { Name => 'HMACAlgorithmSHA1128', Type => 'Label', Unknown => 1 },
'060e2b34.0401.0107.0d010301.020b0100' => { Name => 'EncryptedContainerLabel', Type => 'Label', Unknown => 1 },
'060e2b34.0401.0107.0d010401.02010100' => { Name => 'CryptographicFrameworkLabel', Type => 'Label', Unknown => 1 },
);
# header information
%Image::ExifTool::MXF::Header = (
GROUPS => { 2 => 'Video' },
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
0 => {
Name => 'MXFVersion',
Format => 'int16u[2]',
ValueConv => '$val =~ tr/ /./; $val',
},
# 4 - int32u: KAGSize
# 8 - int64u: bytes from first header
# 16 - int64u: bytes from previous partition
24 => { # bytes to footer from start of header
Name => 'FooterPosition',
Format => 'int64u',
RawConv => '$$self{MXFInfo}{FooterPos} = $val; undef',
},
32 => { # number of bytes in header, beginning at the start of the Primer
Name => 'HeaderSize',
Format => 'int64u',
# use this opportinity to also save our header type
RawConv => q{
$$self{MXFInfo}{HeaderType} = $$self{DIR_NAME};
$$self{MXFInfo}{HeaderSize} = $val;
return undef; # I don't think anyone would care about this
},
},
# ...plus more stuff we don't care about
);
#------------------------------------------------------------------------------
# Convert 16 bytes to UL format
# Inputs: 0) 16-byte value
# Returns: UL string
sub UL($)
{
return join('.', unpack('H8H4H4H8H8', shift));;
}
#------------------------------------------------------------------------------
# Convert latitude and/or longitude in [d]ddmmss(N|S|E|W) format
# Inputs: 0) string value to convert
# Returns: numerical lat and/or long
sub ConvLatLon($)
{
my $val = shift;
my (@convVal, $ne);
foreach $ne ('NS','EW') {
next unless $val =~ /(\d{2,3})(\d{2})(\d{2})([$ne])/;
push @convVal, $1 + ($2 + $3 / 60) / 60 * (($4 eq 'N' or $4 eq 'E') ? 1 : -1);
}
return join ' ', @convVal;
}
#------------------------------------------------------------------------------
# Read MXF-specific Format types
# Inputs: 0) ExifTool ref, 1) value, 2) MXF value type
# Returns: formatted value
# Note: All types recognized here should be defined in the %knownType lookup
sub ReadMXFValue($$$)
{
my ($et, $val, $type) = @_;
my $len = length($val);
local $_;
if ($type eq 'UTF-16') {
$val = $et->Decode($val, 'UTF16');
} elsif ($type eq 'ProductVersion') {
my @a = unpack('n*', $val);
push @a, 0 while @a < 5;
$a[4] = { 0 => 'unknown', 1 => 'released', 2 => 'debug', 3 => 'patched',
4 => 'beta', 5 => 'private build' }->{$a[4]} || "unknown $a[4]";
$val = join('.', @a[0..3]) . ' ' . $a[4];
} elsif ($type eq 'VersionType') {
$val = join('.',unpack('C*',$val));
} elsif ($type eq 'Timestamp') {
my @a = unpack('nC*',$val);
my @max = (3000,12,31,24,59,59,249);
foreach (@a) {
last unless @max and $_ <= $max[0];
shift @max;
}
if (@max) {
$val = 'Invalid (0x' . unpack('H*',$val) . ')';
} else {
$a[6] *= 4;
$val = sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d.%.3d', @a);
}
} elsif ($type eq 'Position' or $type eq 'Length') {
$val = Get64u(\$val, 0);
} elsif ($type eq 'Boolean') {
$val = $val eq "\0" ? 'False' : 'True';
} elsif ($type =~ /^(Alt|Lat|Lon)$/ and $len == 4) {
# split into nibbles after swapping byte order (see reference 8b)
$val = unpack('H*', pack('N', unpack('V', $val)));
( run in 1.488 second using v1.01-cache-2.11-cpan-5b529ec07f3 )