Here's my test script, the patch to MP4::Info is as described earlier. The "scan" code hopefully does your solution justice. Note this particular script currently only tests for the presence of the HDVD flag, it doesn't look at whether it has a value of 1 (720p) or 2 (1080p) - but that shouldn't make any difference for this benchmark.

#!/usr/bin/env perl use warnings FATAL => 'all'; use strict; use 5.010; use MP4::Info 'get_mp4tag'; my %func = ( external => sub { my $file=shift; return `AtomicParsley "$file" -T 1 2>/dev/null`=~/hdvd/i; }, scan => sub { my $file=shift; my $BUFN = 1024; $BUFN *= 4096; my $SIG = '68 64 76 64 00 00 00 11 64 61 74 61 00 00 00 15' .'00 00 00 00 02 00 00 00'; $SIG =~ tr[ ][]d; $SIG = pack 'H*', $SIG; open my $in, '<:raw', $file or die $!; my( $offset, $buffer ) = ( 0, '' ); while( sysread( $in, $buffer, $BUFN, length $buffer ) ) { my $pos = 1+index( $buffer, $SIG ); if( $pos ) { return 1; } $offset += length( $buffer ) - length( $SIG ); $buffer = substr $buffer, - length $SIG; } close $in; return; }, mp4info => sub { my $file=shift; my $tag = get_mp4tag($file) or return; return !!$tag->{HDVD}; }, ); die "Usage: $0 ".join('|',sort keys %func)." PATH\n" unless @ARGV==2 && exists $func{$ARGV[0]} && -d $ARGV[1]; my $FUNC = $ARGV[0]; my $PATH = $ARGV[1]; use File::Find 'find'; my ($yes,$no,$size) = (0,0,0); find({ wanted=>sub { return unless -f && /\.(mp4|m4[apvb])$/i; $size+=-s; if ($func{$FUNC}->($_)) { $yes++; say "YES $_"; } else { $no++; say " no $_"; } }}, $PATH); say "yes=$yes, no=$no, size=$size";

In reply to Re^7: Search hex string in vary large binary file by Anonymous Monk
in thread Search hex string in vary large binary file by westrock2000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.