source: main/trunk/greenstone2/perllib/cpan/Image/ExifTool/MOI.pm@ 34921

Last change on this file since 34921 was 34921, checked in by anupama, 3 years ago

Committing the improvements to EmbeddedMetaPlugin's processing of Keywords vs other metadata fields. Keywords were literally stored as arrays of words rather than phrases in PDFs (at least in Diego's sample PDF), whereas other meta fields like Subjects and Creators stored them as arrays of phrases. To get both to work, Kathy updated EXIF to a newer version, to retrieve the actual EXIF values stored in the PDF. And Kathy and Dr Bainbridge came up with a new option that I added called apply_join_before_split_to_metafields that's a regex which can list the metadata fields to apply the join_before_split to and whcih previously always got applied to all metadata fields. Now it's applied to any *Keywords metafields by default, as that's the metafield we have experience of that behaves differently to the others, as it stores by word instead of phrases. Tested on Diego's sample PDF. Diego has double-checked it to works on his sample PDF too, setting the split char to ; and turning on the join_before_split and leaving apply_join_before_split_to_metafields at its default of .*Keywords. File changes are strings.properties for the tooltip, the plugin introducing the option and working with it and Kathy's EXIF updates affecting cpan/File and cpan/Image.

File size: 4.1 KB
Line 
1#------------------------------------------------------------------------------
2# File: MOI.pm
3#
4# Description: Read MOI meta information
5#
6# Revisions: 2014/12/15 - P. Harvey Created
7#
8# References: 1) https://en.wikipedia.org/wiki/MOI_(file_format)
9#------------------------------------------------------------------------------
10
11package Image::ExifTool::MOI;
12
13use strict;
14use vars qw($VERSION);
15use Image::ExifTool qw(:DataAccess :Utils);
16
17$VERSION = '1.02';
18
19# MOI tags (ref 1)
20%Image::ExifTool::MOI::Main = (
21 GROUPS => { 2 => 'Video' },
22 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
23 NOTES => q{
24 MOI files store information about associated MOD or TOD files, and are
25 written by some JVC, Canon and Panasonic camcorders.
26 },
27 0x00 => { Name => 'MOIVersion', Format => 'string[2]' },
28 # 0x02 => { Name => 'MOIFileSize', Format => 'int32u' },
29 0x06 => {
30 Name => 'DateTimeOriginal',
31 Description => 'Date/Time Original',
32 Format => 'undef[8]',
33 Groups => { 2 => 'Time' },
34 ValueConv => sub {
35 my $val = shift;
36 return undef unless length($val) >= 8;
37 my @v = unpack('nCCCCn', $val);
38 $v[5] /= 1000;
39 return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%06.3f', @v);
40 },
41 PrintConv => '$self->ConvertDateTime($val)',
42 },
43 0x0e => {
44 Name => 'Duration',
45 Format => 'int32u',
46 ValueConv => '$val / 1000',
47 PrintConv => 'ConvertDuration($val)',
48 },
49 0x80 => {
50 Name => 'AspectRatio',
51 Format => 'int8u',
52 PrintConv => q{
53 my $lo = ($val & 0x0f);
54 my $hi = ($val >> 4);
55 my $aspect;
56 if ($lo < 2) {
57 $aspect = '4:3';
58 } elsif ($lo == 4 or $lo == 5) {
59 $aspect = '16:9';
60 } else {
61 $aspect = 'Unknown';
62 }
63 if ($hi == 4) {
64 $aspect .= ' NTSC';
65 } elsif ($hi == 5) {
66 $aspect .= ' PAL';
67 }
68 return $aspect;
69 },
70 },
71 0x84 => {
72 Name => 'AudioCodec',
73 Format => 'int16u',
74 Groups => { 2 => 'Audio' },
75 PrintHex => 1,
76 PrintConv => {
77 0x00c1 => 'AC3',
78 0x4001 => 'MPEG',
79 },
80 },
81 0x86 => {
82 Name => 'AudioBitrate',
83 Format => 'int8u',
84 Groups => { 2 => 'Audio' },
85 ValueConv => '$val * 16000 + 48000',
86 PrintConv => 'ConvertBitrate($val)',
87 },
88 0xda => {
89 Name => 'VideoBitrate',
90 Format => 'int16u',
91 PrintHex => 1,
92 ValueConv => {
93 0x5896 => '8500000',
94 0x813d => '5500000',
95 },
96 PrintConv => 'ConvertBitrate($val)',
97 },
98);
99
100#------------------------------------------------------------------------------
101# Validate and extract metadata from MOI file
102# Inputs: 0) ExifTool ref, 1) dirInfo ref
103# Returns: 1 on success, 0 if this wasn't a valid MOI file
104sub ProcessMOI($$)
105{
106 my ($et, $dirInfo) = @_;
107 my $raf = $$dirInfo{RAF};
108 my $buff;
109 # read enough to allow skipping over run-in if it exists
110 $raf->Read($buff, 256) == 256 and $buff =~ /^V6/ or return 0;
111 if (defined $$et{VALUE}{FileSize}) {
112 my $size = unpack('x2N', $buff);
113 $size == $$et{VALUE}{FileSize} or return 0;
114 }
115 $et->SetFileType();
116 SetByteOrder('MM');
117 my $tagTablePtr = GetTagTable('Image::ExifTool::MOI::Main');
118 return $et->ProcessBinaryData({ DataPt => \$buff }, $tagTablePtr);
119}
120
1211; # end
122
123__END__
124
125=head1 NAME
126
127Image::ExifTool::MOI - Read MOI meta information
128
129=head1 SYNOPSIS
130
131This module is used by Image::ExifTool
132
133=head1 DESCRIPTION
134
135This module contains definitions required by Image::ExifTool to read meta
136information from MOI files.
137
138=head1 AUTHOR
139
140Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
141
142This library is free software; you can redistribute it and/or modify it
143under the same terms as Perl itself.
144
145=head1 REFERENCES
146
147=over 4
148
149=item L<https://en.wikipedia.org/wiki/MOI_(file_format)>
150
151=back
152
153=head1 SEE ALSO
154
155L<Image::ExifTool::TagNames/MOI Tags>,
156L<Image::ExifTool(3pm)|Image::ExifTool>
157
158=cut
159
Note: See TracBrowser for help on using the repository browser.