1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#------------------------------------------------------------------------------
# File: frameCount.config
#
# Description: ExifTool config file to extract MP4 video FrameCount
#
# Usage: exiftool -config frameCount.config -frameCount FILE
#
# Requires: ExifTool version 7.99 or later
#
# Revisions: 2022-09-22 - P. Harvey Created
#
# Notes: Enables Unknown option to extract the required SampleSizes atom
#------------------------------------------------------------------------------
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
'FrameCount' => {
Require => {
0 => 'HandlerType',
},
Desire => {
1 => 'SampleSizes',
2 => 'CompactSampleSizes',
},
Groups => { 2 => 'Video' },
ValueConv => q{
my ($i, $tag, $ptr);
my $key = 'HandlerType';
# find video track number
for ($i=1; defined $val[0]; ++$i) {
last if $val[0] eq 'Video Track';
$key = "HandlerType ($i)";
$val[0] = $self->GetValue($key);
}
my $trk = $self->GetGroup($key, 1);
# search for SampleSizes or CompactSampleSizes for this track
foreach $tag ('SampleSizes', 'CompactSampleSizes') {
$key = $tag;
for ($i=1; ; ++$i) {
$ptr = $self->GetValue($key);
last unless $ptr;
last if $self->GetGroup($key, 1) eq $trk;
$key = "$tag ($i)";
}
last if $ptr;
}
return undef unless $ptr;
return unpack('x8N', $$ptr);
},
},
},
);
%Image::ExifTool::UserDefined::Options = (
Unknown => 1, # (otherwise SampleSizes won't be extracted)
);
|