--- frames.pl 2007/07/19 20:17:06 2 +++ frames.pl 2007/07/21 12:50:32 17 @@ -8,11 +8,19 @@ use GD; use File::Path; +use Getopt::Long; my $tmp = '/tmp/frames'; my $out = '/tmp/frames.avi'; -my $jpeg_q = 10; +my $jpeg_q = 20; +my $repeat = 1; +GetOptions( + "jpeg-q=i" => \$jpeg_q, + "repeat=i" => \$repeat, +); + +rmtree $tmp if -e $tmp; mkpath $tmp || die "can't create $tmp: $!"; my $im = new GD::Image( 160, 120 ); @@ -45,17 +53,20 @@ my $frame = 1; foreach my $c ( @cols ) { - foreach ( 1 .. 16 ) { + foreach ( 1 .. $repeat ) { $im->fill(50,50, col($c) ); - warn "frame $frame\n"; my $path = sprintf('%s/%03d.jpg', $tmp, $frame++); open(my $fh, '>', $path) || die "can't open $path: $!"; print $fh $im->jpeg( $jpeg_q ) || die "can't save picture $path: $!"; close($fh) || die "can't close picture $path: $!"; + warn "frame $frame $jpeg_q% ", -s $path, " bytes\n"; } } -system("ffmpeg -i $tmp/%03d.jpg -r 16 -vcodec copy -y $out") == 0 or - die "encoding failed: $?"; +my $cmd = "ffmpeg -i $tmp/%03d.jpg -r 16 -y $out"; +warn "## $cmd\n"; +system($cmd) == 0 or die "encoding failed: $?"; + +#rmdir $tmp || die "can't remove $tmp: $!"; -rmdir $tmp || die "can't remove $tmp: $!"; +warn "created $out ", -s $out, " bytes\n";