#!/usr/bin/perl 
use strict;
use warnings;

sub UsageInfo {
  print "Usage:\n";
  print "stretch ratio -- stretches (ratio > 1) or shrinks (ratio < 1)\n\n";
}

if ( $#ARGV != 0 ) {
  UsageInfo;
  exit 1;
}

my $fRatio = $ARGV[0];

my $t1;
my $t2;

my $n;
my $period;
my $sline;
my $subtitle;

while ( 1 ) {
  $n = <STDIN>;
  $n or last;

  $period = <STDIN>;
  $period or last;
  $period =~ /(..):(..):(..),(...) --> (..):(..):(..),(...)/ or last;
  $t1 = ($1 * 3600 + $2 * 60 + $3.".".$4)*$fRatio;
  $t2 = ($5 * 3600 + $6 * 60 + $7.".".$8)*$fRatio;

  $subtitle = "";
  $subtitle .= $sline while ( defined($sline = <STDIN>) && ($sline ne "\r\n") && ($sline ne "\n") );
  $sline or last;

  print $n;

  printf("%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n",
	 $t1/3600, $t1%3600/60, $t1%60, 1000*($t1 - int($t1)),
	 $t2/3600, $t2%3600/60, $t2%60, 1000*($t2 - int($t2)) );
  print $subtitle;
  print "\r\n";
}

