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 |
|
---|
11 | package Image::ExifTool::MOI;
|
---|
12 |
|
---|
13 | use strict;
|
---|
14 | use vars qw($VERSION);
|
---|
15 | use 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
|
---|
104 | sub 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 |
|
---|
121 | 1; # end
|
---|
122 |
|
---|
123 | __END__
|
---|
124 |
|
---|
125 | =head1 NAME
|
---|
126 |
|
---|
127 | Image::ExifTool::MOI - Read MOI meta information
|
---|
128 |
|
---|
129 | =head1 SYNOPSIS
|
---|
130 |
|
---|
131 | This module is used by Image::ExifTool
|
---|
132 |
|
---|
133 | =head1 DESCRIPTION
|
---|
134 |
|
---|
135 | This module contains definitions required by Image::ExifTool to read meta
|
---|
136 | information from MOI files.
|
---|
137 |
|
---|
138 | =head1 AUTHOR
|
---|
139 |
|
---|
140 | Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
|
---|
141 |
|
---|
142 | This library is free software; you can redistribute it and/or modify it
|
---|
143 | under 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 |
|
---|
155 | L<Image::ExifTool::TagNames/MOI Tags>,
|
---|
156 | L<Image::ExifTool(3pm)|Image::ExifTool>
|
---|
157 |
|
---|
158 | =cut
|
---|
159 |
|
---|