Hi,
I'm trying to read video duration. The -Composite:Duration tag works well for me, but I've noticed that it does not work for ASF/WMV format videos. ASF:PlayDuration seems to work for these.
Just wondering if this can/should be integrated into the built in -Composite:Duration tag.
I realise that ASF metadata is not writable, but that's ok for my use case because I am only interested in reading.
I've attempted to make my own readonly composite tag (see below). I've named it Duration_ to avoid the circular dependency on Composite:Duration. I know there's probably a better way to override Composite:Duration but I have not figured it out yet.
Here is my config file code:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
Duration_ => {
Writable => 0,
Desire => {
0 => 'Duration',
1 => 'ASF:PlayDuration',
},
ValueConv => q{
return $val[0] if defined $val[0];
return $val[1] if defined $val[1];
return undef;
},
},
},
);
This seems to work on my data but have not tested it comprehensively. Would appreciate any tips/improvements or recommendation of a better way to do this.
Thanks.
Very good. It is fine as you have it, but the ValueConv can be simplified a bit, and you could add a print conversion so the output is in the same format as the existing Duration:
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
Duration_ => {
Writable => 0,
Desire => {
0 => 'Duration',
1 => 'ASF:PlayDuration',
},
ValueConv => '$val[0] || $val[1]',
PrintConv => 'ConvertDuration($val)',
},
},
);
- Phil
Great. Thanks very much for your quick reply.
About your suggestion of building it into the existing duration: The thing to do would be to add yet another Composite:Duration tag, because all of the others are particular to their specific file formats. (See the Composite tags documentation for details (https://exiftool.org/TagNames/Composite.html).) I'll think about this.
- Phil
Rather than adding another Composite tag, I have renamed PlayDuration to just Duration in ExifTool 10.76.
- Phil
Thank you, that seems like a good fix.