/[amv]/frames.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /frames.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by dpavlin, Thu Jul 19 20:17:06 2007 UTC revision 17 by dpavlin, Sat Jul 21 12:50:32 2007 UTC
# Line 8  use strict; Line 8  use strict;
8    
9  use GD;  use GD;
10  use File::Path;  use File::Path;
11    use Getopt::Long;
12    
13  my $tmp = '/tmp/frames';  my $tmp = '/tmp/frames';
14  my $out = '/tmp/frames.avi';  my $out = '/tmp/frames.avi';
15  my $jpeg_q = 10;  my $jpeg_q = 20;
16    my $repeat = 1;
17    
18    GetOptions(
19            "jpeg-q=i" => \$jpeg_q,
20            "repeat=i" => \$repeat,
21    );
22    
23    rmtree $tmp if -e $tmp;
24  mkpath $tmp || die "can't create $tmp: $!";  mkpath $tmp || die "can't create $tmp: $!";
25    
26  my $im = new GD::Image( 160, 120 );  my $im = new GD::Image( 160, 120 );
# Line 45  my @cols = ( Line 53  my @cols = (
53  my $frame = 1;  my $frame = 1;
54    
55  foreach my $c ( @cols ) {  foreach my $c ( @cols ) {
56          foreach ( 1 .. 16 ) {          foreach ( 1 .. $repeat ) {
57                  $im->fill(50,50, col($c) );                  $im->fill(50,50, col($c) );
                 warn "frame $frame\n";  
58                  my $path = sprintf('%s/%03d.jpg', $tmp, $frame++);                  my $path = sprintf('%s/%03d.jpg', $tmp, $frame++);
59                  open(my $fh, '>', $path) || die "can't open $path: $!";                  open(my $fh, '>', $path) || die "can't open $path: $!";
60                  print $fh $im->jpeg( $jpeg_q ) || die "can't save picture $path: $!";                  print $fh $im->jpeg( $jpeg_q ) || die "can't save picture $path: $!";
61                  close($fh) || die "can't close picture $path: $!";                  close($fh) || die "can't close picture $path: $!";
62                    warn "frame $frame $jpeg_q% ", -s $path, " bytes\n";
63          }          }
64  }  }
65    
66  system("ffmpeg -i $tmp/%03d.jpg -r 16 -vcodec copy -y $out") == 0 or  my $cmd = "ffmpeg -i $tmp/%03d.jpg -r 16 -y $out";
67          die "encoding failed: $?";  warn "## $cmd\n";
68    system($cmd) == 0 or die "encoding failed: $?";
69    
70    #rmdir $tmp || die "can't remove $tmp: $!";
71    
72  rmdir $tmp || die "can't remove $tmp: $!";  warn "created $out ", -s $out, " bytes\n";

Legend:
Removed from v.2  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.26