switch to pdftoppm for rendering (thanks, damjan)
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 16 Dec 2009 21:56:40 +0000 (22:56 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 16 Dec 2009 21:56:40 +0000 (22:56 +0100)
this inwolved shuffling the code around, but now we can create
hires presetation png files directly from presentation.pdf symlink

bin/mplayer.pl

index 74a4c5c..090d264 100755 (executable)
@@ -3,6 +3,8 @@
 use warnings;
 use strict;
 
+use autodie;
+
 use IPC::Open3 qw(open3);
 use IO::Select;
 use Data::Dump qw(dump);
@@ -227,21 +229,6 @@ sub html5tv {
                push @slide_t, $s->[0];
        }
 
-       if ( @frames ) {
-               rmdir $_ foreach glob "$media_dir/s/[124]";
-               my $hires = "$media_dir/s/hires";
-               mkdir $hires unless -e $hires;
-
-               oggThumb $movie, "$hires/.f%.jpg", map { $_->[0] } @frames;
-
-               foreach my $i ( 0 .. $#frames ) {
-                       my $from = "$hires/.f$i.jpg";
-                       my $to   = "$hires/f" . $frames[$i]->[1] . '.jpg';
-                       rename $from, $to || warn "can't rename $from -> $to: $!";
-               }
-
-       }
-
        foreach ( 0 .. $#slide_t ) {
                my $slide_nr = $_ + 1;
                push @{ $sync->{htmlEvents}->{'#slide'} }, {
@@ -251,16 +238,46 @@ sub html5tv {
                };
        }
 
-       my @slides_hires = glob "$media_dir/s/hires/*";
 
-       my $path = "$media_dir/s";
+       my $max_slide_height = 480; # XXX
+
+       my $path  = "$media_dir/s";
+       my $hires = "$media_dir/s/hires";
 
        if ( ! -d $path ) {
-               warn "create slides images in $path";
+               warn "create slides in $path";
                mkdir $path;
+               mkdir $hires;
+
+               my $path = "$media_dir/presentation.pdf";
+               $path = $media_dir . '/' . readlink($path) if -l $path;
+
+warn "XX $path";
+
+               if ( -e $path ) {
+                       warn "render pdf slides from $path\n";
+                       system "pdftoppm -png -r 100 $path $hires/p";
+               }
        }
 
-       my $max_slide_height = 480; # XXX
+
+       if ( @frames ) {
+               warn "create slides from video frames";
+               rmdir $_ foreach glob "$media_dir/s/[124]";
+
+               oggThumb $movie, "$hires/.f%.jpg", map { $_->[0] } @frames;
+
+               foreach my $i ( 0 .. $#frames ) {
+                       my $from = "$hires/.f$i.jpg";
+                       my $to   = "$hires/f" . $frames[$i]->[1] . '.jpg';
+                       rename $from, $to || warn "can't rename $from -> $to: $!";
+               }
+
+       }
+
+
+       my @slides_hires = glob "$hires/*";
+
 
        foreach my $hires ( @slides_hires ) {