Revision 26

Date:
2007/08/18 11:21:00
Author:
dpavlin
Revision Log:
very jpeg quality, repeat frames and encode audio in movie
Files:

Legend:

 
Added
 
Removed
 
Modified
  • frames.pl

     
    14 14 my $out = '/tmp/frames.avi';
    15 15 my $jpeg_q = 100;
    16 16 my $repeat = 1;
    17 my $vary_jpeg_q = 0;
    18 $repeat = 16;
    19 my $audio = '-i /tmp/test-pcm.wav';
    17 20
    18 21 GetOptions(
    19 22 "jpeg-q=i" => \$jpeg_q,
     
    71 74 my $path = sprintf('%s/%03d.jpg', $tmp, $frame);
    72 75 save_jpeg( $path, $jpeg_q );
    73 76
    74 foreach my $q ( 1 .. 100 ) {
    75 my $path = sprintf('%s/%03d-q%03d.jpg', $tmp, $frame, $q );
    76 save_jpeg( $path, $q );
    77 if ( $vary_jpeg_q ) {
    78 foreach my $q ( 1 .. 100 ) {
    79 my $path = sprintf('%s/%03d-q%03d.jpg', $tmp, $frame, $q );
    80 save_jpeg( $path, $q );
    81 }
    77 82 }
    83
    78 84 warn "frame $frame $jpeg_q% ", -s $path, " bytes\n";
    79 85 $frame++;
    80 86 }
    81 87 }
    82 88
    83 my $cmd = "ffmpeg -i $tmp/%03d.jpg -r 16 -y $out";
    89 my $cmd = "ffmpeg -i $tmp/%03d.jpg $audio -r 16 -vcodec mjpeg -acodec adpcm_ms -ar 22050 -y $out";
    84 90 warn "## $cmd\n";
    85 91 system($cmd) == 0 or die "encoding failed: $?";
    86 92