- Timestamp:
- 2021-02-26T19:39:51+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/Matroska.pm
r24107 r34921 15 15 use Image::ExifTool qw(:DataAccess :Utils); 16 16 17 $VERSION = '1. 04';17 $VERSION = '1.10'; 18 18 19 19 my %noYes = ( 0 => 'No', 1 => 'Yes' ); … … 24 24 %Image::ExifTool::Matroska::Main = ( 25 25 GROUPS => { 2 => 'Video' }, 26 VARS => { NO_LOOKUP => 1 }, # omit tags from lookup 26 27 NOTES => q{ 27 28 The following tags are extracted from Matroska multimedia container files. 28 29 This container format is used by file types such as MKA, MKV, MKS and WEBM. 29 30 For speed, ExifTool extracts tags only up to the first Cluster unless the 30 Verbose (-v) or Unknown= 2 (-U) option is used. See31 L<Verbose|../ExifTool.html#Verbose> (-v) or L<Unknown|../ExifTool.html#Unknown> = 2 (-U) option is used. See 31 32 L<http://www.matroska.org/technical/specs/index.html> for the official 32 33 Matroska specification. … … 151 152 }, 152 153 0x67 => { 153 Name => 'Time code',154 Name => 'TimeCode', 154 155 Format => 'unsigned', 155 156 Unknown => 1, … … 221 222 0x2e => { 222 223 Name => 'TrackEntry', 224 # reset TrackType member at the start of each track 225 Condition => 'delete $$self{TrackType}; 1', 223 226 SubDirectory => { TagTable => 'Image::ExifTool::Matroska::Main' }, 224 227 }, … … 632 635 0x487 => { Name => 'TagString', Format => 'utf8' }, 633 636 0x485 => { Name => 'TagBinary', Binary => 1 }, 637 # 638 # Spherical Video V2 (untested) 639 # 640 0x7670 => { 641 Name => 'Projection', 642 SubDirectory => { TagTable => 'Image::ExifTool::Matroska::Projection' }, 643 }, 644 ); 645 646 # Spherical video v2 projection tags (ref https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md) 647 %Image::ExifTool::Matroska::Projection = ( 648 GROUPS => { 2 => 'Video' }, 649 VARS => { NO_LOOKUP => 1 }, # omit tags from lookup 650 NOTES => q{ 651 Projection tags defined by the Spherical Video V2 specification. See 652 L<https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md> 653 for the specification. 654 }, 655 0x7671 => { 656 Name => 'ProjectionType', 657 Format => 'unsigned', 658 DataMember => 'ProjectionType', 659 RawConv => '$$self{ProjectionType} = $val', 660 PrintConv => { 661 0 => 'Rectangular', 662 1 => 'Equirectangular', 663 2 => 'Cubemap', 664 3 => 'Mesh', 665 }, 666 }, 667 0x7672 => [{ 668 Name => 'EquirectangularProj', 669 Condition => '$$self{ProjectionType} == 1', 670 SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::equi' }, 671 },{ 672 Name => 'CubemapProj', 673 Condition => '$$self{ProjectionType} == 2', 674 SubDirectory => { TagTable => 'Image::ExifTool::QuickTime::cbmp' }, 675 }], 676 0x7673 => { Name => 'ProjectionPosYaw', Format => 'float' }, 677 0x7674 => { Name => 'ProjectionPosPitch', Format => 'float' }, 678 0x7675 => { Name => 'ProjectionPosRoll', Format => 'float' }, 634 679 ); 635 680 … … 673 718 sub ProcessMKV($$) 674 719 { 675 my ($e xifTool, $dirInfo) = @_;720 my ($et, $dirInfo) = @_; 676 721 my $raf = $$dirInfo{RAF}; 677 722 my ($buff, $buf2, @dirEnd, $trackIndent, %trackTypes); … … 688 733 my $hlen = GetVInt($buff, $pos); 689 734 return 0 unless $hlen and $hlen > 0; 690 $pos + $hlen > $dataLen and $e xifTool->Warn('Truncated Matroska header'), return 1;691 $e xifTool->SetFileType();735 $pos + $hlen > $dataLen and $et->Warn('Truncated Matroska header'), return 1; 736 $et->SetFileType(); 692 737 SetByteOrder('MM'); 693 738 my $tagTablePtr = GetTagTable('Image::ExifTool::Matroska::Main'); 694 739 695 740 # set flag to process entire file (otherwise we stop at the first Cluster) 696 my $verbose = $e xifTool->Options('Verbose');697 my $processAll = ($verbose or $e xifTool->Options('Unknown') > 1);698 $$e xifTool{TrackTypes} = \%trackTypes; # store Track types reference699 my $oldIndent = $$e xifTool{INDENT};741 my $verbose = $et->Options('Verbose'); 742 my $processAll = ($verbose or $et->Options('Unknown') > 1); 743 $$et{TrackTypes} = \%trackTypes; # store Track types reference 744 my $oldIndent = $$et{INDENT}; 700 745 my $chapterNum = 0; 701 746 … … 705 750 pop @dirEnd; 706 751 # use INDENT to decide whether or not we are done this Track element 707 delete $$e xifTool{SET_GROUP1} if $trackIndent and $trackIndent eq $$exifTool{INDENT};708 $$e xifTool{INDENT} = substr($$exifTool{INDENT}, 0, -2);752 delete $$et{SET_GROUP1} if $trackIndent and $trackIndent eq $$et{INDENT}; 753 $$et{INDENT} = substr($$et{INDENT}, 0, -2); 709 754 } 710 755 # read more if we are getting close to the end of our buffer … … 724 769 $size < 0 and $unknownSize = 1, $size = 1e20; 725 770 if (@dirEnd and $pos + $dataPos + $size > $dirEnd[-1][0]) { 726 $e xifTool->Warn("Invalid or corrupted $dirEnd[-1][1] master element");771 $et->Warn("Invalid or corrupted $dirEnd[-1][1] master element"); 727 772 $pos = $dirEnd[-1][0] - $dataPos; 728 773 if ($pos < 0 or $pos > $dataLen) { … … 735 780 next; 736 781 } 737 my $tagInfo = $e xifTool->GetTagInfo($tagTablePtr, $tag);782 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag); 738 783 # just fall through into the contained EBML elements 739 784 if ($tagInfo and $$tagInfo{SubDirectory}) { 740 785 # stop processing at first cluster unless we are in verbose mode 741 786 last if $$tagInfo{Name} eq 'Cluster' and not $processAll; 742 $$e xifTool{INDENT} .= '| ';743 $e xifTool->VerboseDir($$tagTablePtr{$tag}{Name}, undef, $size);787 $$et{INDENT} .= '| '; 788 $et->VerboseDir($$tagTablePtr{$tag}{Name}, undef, $size); 744 789 push @dirEnd, [ $pos + $dataPos + $size, $$tagInfo{Name} ]; 745 790 if ($$tagInfo{Name} eq 'ChapterAtom') { 746 $$e xifTool{SET_GROUP1} = 'Chapter' . (++$chapterNum);747 $trackIndent = $$e xifTool{INDENT};791 $$et{SET_GROUP1} = 'Chapter' . (++$chapterNum); 792 $trackIndent = $$et{INDENT}; 748 793 } 749 794 next; … … 756 801 if (not $tagInfo or $more > 10000000) { 757 802 # don't try to skip very large blocks unless LargeFileSupport is enabled 758 last if $more > 0x80000000 and not $exifTool->Options('LargeFileSupport');803 last if $more >= 0x80000000 and not $et->Options('LargeFileSupport'); 759 804 $raf->Seek($more, 1) or last; 760 805 $buff = ''; … … 786 831 if ($fmt eq 'string' or $fmt eq 'utf8') { 787 832 ($val = substr($buff, $pos, $size)) =~ s/\0.*//s; 788 $val = $e xifTool->Decode($val, 'UTF8') if $fmt eq 'utf8';833 $val = $et->Decode($val, 'UTF8') if $fmt eq 'utf8'; 789 834 } elsif ($fmt eq 'float') { 790 835 if ($size == 4) { … … 793 838 $val = GetDouble(\$buff, $pos); 794 839 } else { 795 $e xifTool->Warn("Illegal float size ($size)");840 $et->Warn("Illegal float size ($size)"); 796 841 } 797 842 } else { … … 821 866 # set group1 to Track/Chapter number 822 867 if ($$tagInfo{Name} eq 'TrackNumber') { 823 $$e xifTool{SET_GROUP1} = 'Track' . $val;824 $trackIndent = $$e xifTool{INDENT};868 $$et{SET_GROUP1} = 'Track' . $val; 869 $trackIndent = $$et{INDENT}; 825 870 } 826 871 } … … 832 877 ); 833 878 if ($$tagInfo{NoSave}) { 834 $e xifTool->VerboseInfo($tag, $tagInfo, Value => $val, %parms) if $verbose;879 $et->VerboseInfo($tag, $tagInfo, Value => $val, %parms) if $verbose; 835 880 } else { 836 $e xifTool->HandleTag($tagTablePtr, $tag, $val, %parms);881 $et->HandleTag($tagTablePtr, $tag, $val, %parms); 837 882 } 838 883 $pos += $size; # step to next element 839 884 } 840 $$e xifTool{INDENT} = $oldIndent;841 delete $$e xifTool{SET_GROUP1};885 $$et{INDENT} = $oldIndent; 886 delete $$et{SET_GROUP1}; 842 887 # override file type if necessary based on existing track types 843 888 unless ($trackTypes{0x01} or $trackTypes{0x03}) { # video or complex? 844 889 if ($trackTypes{0x02}) { # audio? 845 $e xifTool->OverrideFileType('MKA');890 $et->OverrideFileType('MKA'); 846 891 } elsif ($trackTypes{0x11}) { # subtitle? 847 $e xifTool->OverrideFileType('MKS');892 $et->OverrideFileType('MKS'); 848 893 } 849 894 } … … 870 915 =head1 AUTHOR 871 916 872 Copyright 2003-20 11, Phil Harvey (phil at owl.phy.queensu.ca)917 Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com) 873 918 874 919 This library is free software; you can redistribute it and/or modify it … … 889 934 890 935 =cut 891
Note:
See TracChangeset
for help on using the changeset viewer.