/[amv]/amv.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 /amv.pl

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

revision 22 by dpavlin, Sat Jul 21 15:17:48 2007 UTC revision 23 by dpavlin, Sat Jul 21 17:03:56 2007 UTC
# Line 23  my $dump_dir = '/tmp/dump/'; Line 23  my $dump_dir = '/tmp/dump/';
23  my $dump_avi = "dump.avi";  my $dump_avi = "dump.avi";
24  my $no_jpeg_header = 0;  my $no_jpeg_header = 0;
25  my $jpeg_q = 100;  my $jpeg_q = 100;
26    my $jpegtran = '-flip vertical';
27    
28  GetOptions(  GetOptions(
29          "dump!"                 => \$dump,          "dump!"                 => \$dump,
30          "debug!"                => \$debug,          "debug!"                => \$debug,
31          "dump-dir=s"    => \$dump_dir,          "dump-dir=s"    => \$dump_dir,
32          "no-jpeg-headers!" => \$no_jpeg_header,          "no-jpeg-headers!" => \$no_jpeg_header,
33            "jpegtran=s"    => \$jpegtran
34  );  );
35    
36  my $path = shift @ARGV || die "usage: $0 movie.amv\n";  my $path = shift @ARGV || die "usage: $0 movie.amv\n";
# Line 161  sub mkjpg { Line 163  sub mkjpg {
163                  return;                  return;
164          }          }
165    
         my $path = sprintf("$dump_dir/%04d.jpg", $frame_nr++ );  
   
         open(my $fh, '>', $path) || die "can't create $path: $!";  
   
166          my $w = $d->{amvh}->{width} || die "no width?";          my $w = $d->{amvh}->{width} || die "no width?";
167          my $h = $d->{amvh}->{height} || confess "no height?";          my $h = $d->{amvh}->{height} || confess "no height?";
168    
# Line 295  sub mkjpg { Line 293  sub mkjpg {
293          my $frame = join('', @subframes ) . $data;          my $frame = join('', @subframes ) . $data;
294          @subframes = ();          @subframes = ();
295    
296            my $path = sprintf("$dump_dir/%04d.jpg", $frame_nr++ );
297    
298            my $fh;
299            if ( $jpegtran ) {
300                    open($fh, '|-', "jpegtran $jpegtran > $path") || die "can't create $path: $!";
301            } else {
302                    open($fh, '>', $path) || die "can't create $path: $!";
303            }
304    
305          if ( ! $no_jpeg_header ) {          if ( ! $no_jpeg_header ) {
306                  print $fh $header, $frame, "\xFF\xD9" || die "can't write jpeg $path: $!";                  print $fh $header . $frame . "\xFF\xD9" || die "can't write jpeg $path: $!";
307          } else {          } else {
308                  print $fh $frame || die "can't write raw jpeg $path: $!";                  print $fh $frame || die "can't write raw jpeg $path: $!";
309          }          }
# Line 356  while ( ! defined($d->{eof}) ) { Line 363  while ( ! defined($d->{eof}) ) {
363          }          }
364  }  }
365    
366  my $cmd = "ffmpeg -i $dump_dir/%04d.jpg -r 16 -f $dump_avi";  my $cmd = "ffmpeg -i $dump_dir/%04d.jpg -r 16 -y $dump_avi";
367  system($cmd) == 0 || die "can't convert frames to avi using $cmd: $!";  system($cmd) == 0 || die "can't convert frames to avi using $cmd: $!";
368    

Legend:
Removed from v.22  
changed lines
  Added in v.23

  ViewVC Help
Powered by ViewVC 1.1.26