Fellow monks, after browsing the CPAN last week , and giving the super-search a try I was forced (by the immediacy of production pressure) to roll something of my own , that I am certain exists somewhere.

The challenge set was to 'rationalise' multiple time ranges, to determine how many, if any overlap hence forming concurrent blocks. Why? - in this case to process a SMPTE EDL (Edit Decision List) and reduce the number of individual 'edits' , particularly overlapping edits required to import the necessary frames, but avoid the duplication of grabbing 00:01:10:00 - 00:01:15:05 then later 00:01:14:02 - 00:01:18:20.

Since EDL's deal with video/film their smallest quantity is the frame (pls nobody remind me about fields!!) , and depending on the format , one second of footage is 24, or 25, or 30 frames. What I was searching for was a module that allowed creating a counter that one can set arbitary values for the carry to next column. For SMPTE PAL video, this would mean 25frames to each second, 60 seconds to each minute, 60 minutes to the hour.

Ultimatly I rolled a module that creates edit objects with properties like in and out point. To apply the range logic to them, timecode in the format HH:MM:SS:FF was converted to integers in its lowest atomic - the frame.

package timecode; our $fps = 25; sub fps { $fps = $_[1]; } sub _smpte2int { my $tc = shift; my @hmsf = split ':' , $tc; my ($hours , $mins, $secs , $frames); $hours = 60*60*$fps*$hmsf[0]; $mins = 60*$fps* $hmsf[1]; $secs = $fps * $hmsf[2]; $frames= $hmsf[3]; return $hours+$mins+$secs+$frames; } sub _int2smpte { my $int = shift; my ($hours , $mins , $secs , $frames); my $r; $r = $int % ($fps*60*60); $hours = sprintf '%02d' , int ( ($int-$r) / ($fps*60*60) ) ; $int = $r; $r = $int % ($fps*60); $mins = sprintf '%02d' , int ( ($int-$r) / ($fps*60) ); $int = $r; $r = $int % ($fps); $secs = sprintf '%02d' , int ( ($int-$r) / ($fps) ); $int = $r; $frames = sprintf '%02d' , $int; return join ":", $hours,$mins,$secs,$frames ; } sub new { my $self = shift; my %tc = @_; #@tc{qw/in out/} = ( _smpte2int($in) , _smpte2int($out) ); die @_ unless ( defined $tc{in} ); die @_ unless (defined $tc{out}); $tc{in} = _smpte2int($tc{in}); $tc{out} = _smpte2int($tc{out}); return bless \%tc, $self; } sub copy { my $self=shift; my $ref =shift; my %tc = %$ref; return bless \%tc, $self; } sub asEdl { my $self = shift; my $in = _int2smpte($self->{in}); my $out= _int2smpte($self->{out}); return join '' , $self->{event}, ' 'x2, $self->{roll}, ' 'x6, $self->{channel}, ' 'x5, $self->{type}, ' 'x8, "$in $out $in $out \n"; } sub check { my $self = shift; return _int2smpte ( $self->{in} ) , _int2smpte( $self->{out} ); }

There's a question in here somewhere I know it... the wisdom I seek is the name of the module I've made bastardized hack of. I'm not sure of the best words to describe it... counters of arbitary range? no... erm... help!


I can't believe it's not psellchecked

In reply to Processing timeranges with unusual precision. by submersible_toaster

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.