/[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 17 by dpavlin, Sat Jul 21 12:50:32 2007 UTC revision 18 by dpavlin, Sat Jul 21 15:02:51 2007 UTC
# Line 12  use Getopt::Long; Line 12  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 = 20;  my $jpeg_q = 100;
16  my $repeat = 1;  my $repeat = 1;
17    
18  GetOptions(  GetOptions(
# Line 41  sub col { Line 41  sub col {
41  }  }
42    
43  my @cols = (  my @cols = (
44            'fff',
45          '000',          '000',
46          'f00',          'f00',
47            '000',
48          '0f0',          '0f0',
49            '000',
50          '00f',          '00f',
51            '000',
52          'ff0',          'ff0',
53            '000',
54          '0ff',          '0ff',
55            '000',
56          'fff',          'fff',
57  );  );
58    
59  my $frame = 1;  my $frame = 1;
60    
61    sub save_jpeg {
62            my ( $path, $q ) = @_;
63            open(my $fh, '>', $path ) || die "can't open $path: $!";
64            print $fh $im->jpeg( $q ) || die "can't save picture $path: $!";
65            close($fh) || die "can't close picture $path: $!";
66    }
67    
68  foreach my $c ( @cols ) {  foreach my $c ( @cols ) {
69          foreach ( 1 .. $repeat ) {          foreach ( 1 .. $repeat ) {
70                  $im->fill(50,50, col($c) );                  $im->fill(50,50, col($c) );
71                  my $path = sprintf('%s/%03d.jpg', $tmp, $frame++);                  my $path = sprintf('%s/%03d.jpg', $tmp, $frame);
72                  open(my $fh, '>', $path) || die "can't open $path: $!";                  save_jpeg( $path, $jpeg_q );
73                  print $fh $im->jpeg( $jpeg_q ) || die "can't save picture $path: $!";  
74                  close($fh) || die "can't close picture $path: $!";                  foreach my $q ( 1 .. 100 ) {
75                            my $path = sprintf('%s/%03d-q%03d.jpg', $tmp, $frame, $q );
76                            save_jpeg( $path, $q );
77                    }
78                  warn "frame $frame $jpeg_q% ", -s $path, " bytes\n";                  warn "frame $frame $jpeg_q% ", -s $path, " bytes\n";
79                    $frame++;
80          }          }
81  }  }
82    

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

  ViewVC Help
Powered by ViewVC 1.1.26