#!perl use strict; use warnings; #use diagnostics; use Data::Dump::Streamer; my $file_types = join '|', qw( avi m4v mov mp4 mpeg rmvb wmv ); my $empty_re = qr{ \A \s* \z }msx; my $filename_re = qr{ \A ( [A-Z] : \\ .+? \. (?:$file_types) ) \s* \z +}msx; my $audio_re = qr{ \A \s+ Stream [ ] \#\d+\.\d+ (?: \(eng\) | \[0x[0-9a-f]+\] )? : [ ] Audio: [ ] ( mp[23] | aac | qdm2 | cook | wmav2 ), # 1 [ ] (\d+)[ ]Hz, # 2 [ ] (mono|stereo) # 3 (?: , [ ] (\d+)[ ]kb/s )? # 4 \s* \z }msx; my $video_re = qr{ \A \s+ Stream [ ] \#\d+\.\d+ (?: \(eng\) | \[0x[0-9a-f]+\] )? : [ ] Video: [ ] ( mpeg4 | h264 | svq3 | mpeg4 | mpeg1video | wmv1 | RV40 ) # + 1 (?: [ ]/ | ,) [ ] ( yuv420p | 0x[0-9a-f]+ ), # + 2 [ ] (\d+)x(\d+) # + 3,4 (?: , [ ] (\d+)[ ]kb/s )? # + 5 , [ ] ( \d+ (?: \. \d+ )? ) [ ] fps\(r\) # + 6 \s* \z }msx; my ( $filename, $ar, $x, $y, $vr, $fps ); while (<DATA>) { if ( /$filename_re/ ) { $filename = $1; next; } if ( /$audio_re/ ) { $ar = $4; next; } if ( /$video_re/ ) { ( $x, $y, $vr, $fps ) = ( $3, $4, $5, $6 ); next; } if ( /$empty_re/ ) { Dump [ $filename, $ar, $x, $y, $vr, $fps ]; undef $_ for ( $filename, $ar, $x, $y, $vr, $fps ); next; } warn "Unrecognized line '$_' "; }; __DATA__ E:\jyb.avi Stream #0.1: Audio: mp3, 44100 Hz, mono, 80 kb/s Stream #0.0: Video: mpeg4, yuv420p, 464x240, 25.00 fps(r) E:\weit.m4v Stream #0.0(eng): Audio: aac, 44100 Hz, stereo Stream #0.1(eng): Video: h264, yuv420p, 320x240, 15.00 fps(r) E:\otm.mov Stream #0.1(eng): Audio: qdm2, 44100 Hz, stereo Stream #0.0(eng): Video: svq3, yuv420p, 320x240, 24.00 fps(r) E:\bo.mp4 Stream #0.1(eng): Audio: aac, 44100 Hz, stereo Stream #0.0(eng): Video: mpeg4, yuv420p, 320x240, 25.00 fps(r) E:\tom.mpeg Stream #0.1[0x1c0]: Audio: mp2, 44100 Hz, stereo, 256 kb/s Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x240, 1180 kb/s, +29.97 fps(r) E:\gb.rmvb Stream #0.1: Audio: cook, 44100 Hz, stereo, 44 kb/s Stream #0.0: Video: RV40 / 0x30345652, 352x288, 180 kb/s, 12.00 fps( +r) E:\xt.wmv Stream #0.0: Audio: wmav2, 32000 Hz, stereo, 32 kb/s Stream #0.1: Video: wmv1, yuv420p, 320x240, 15.00 fps(r)

In reply to Re: conditional regex by Util
in thread conditional regex by Anonymous Monk

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.