more markers
[HTML5TV.git] / bin / video-timecoded.pl
index 6207f08..179dbae 100755 (executable)
@@ -7,11 +7,19 @@ use Graphics::Magick;
 use File::Path qw(rmtree);
 
 my $length = 100;
-my $fps = 10;
+my $fps = 5;
+
+if ( my $original = shift @ARGV ) {
+       my $len_ms = `oggLength $original`;
+       $length = int( ( $len_ms + 500 ) / 1000 );
+       warn "$original\t$length s\n";
+}
 
 rmtree "/tmp/blank";
 mkdir "/tmp/blank";
 
+my $frame_fmt = '/tmp/blank/f%08d.jpg';
+
 foreach my $pos ( 0 .. $length * $fps ) {
 
        my $im = Graphics::Magick->new( size => '320x200' );
@@ -26,10 +34,16 @@ foreach my $pos ( 0 .. $length * $fps ) {
                text => sprintf("%02d:%02d:%06.3f", $hh, $mm, $ss ),
                fill => 'yellow',
        );
-       my $path = sprintf "/tmp/blank/f%04d.jpg", $pos;
+       my $path = sprintf $frame_fmt, $pos;
        $im->Write( filename => $path );
-       warn "# $hh $mm $ss $path ", -s $path, $/;
+#      warn "# $hh $mm $ss $path ", -s $path, $/ if $t % $fps == 0;
+       print STDERR $pos % 60 * $fps == 0 ? '*' : '.' if $pos % $fps == 0;
 }
 
+print STDERR "\n";
+
 #system "oggSlideshow -f $fps -o /tmp/blank.ogv -d 20000 -e -l $fps -t p /tmp/blank/f*";
-system "ffmpeg2theora --framerate $fps -o /tmp/blank.ogv /tmp/blank/f%04d.jpg";
+system "ffmpeg2theora --framerate $fps --keyint $fps -o /tmp/blank.ogv $frame_fmt";
+
+rmtree "/tmp/blank";
+