/[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 24 by dpavlin, Sun Jul 22 11:05:47 2007 UTC revision 27 by dpavlin, Sat Aug 18 11:21:40 2007 UTC
# Line 10  Line 10 
10  # http://www.obrador.com/essentialjpeg/HeaderInfo.htm  # http://www.obrador.com/essentialjpeg/HeaderInfo.htm
11  # http://lists.helixcommunity.org/pipermail/datatype-dev/2005-January/001886.html  # http://lists.helixcommunity.org/pipermail/datatype-dev/2005-January/001886.html
12  # http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm  # http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm
13    # http://wiki.multimedia.cx/index.php?title=IMA_ADPCM
14    
15  use strict;  use strict;
16    
# Line 18  use Carp qw/confess/; Line 19  use Carp qw/confess/;
19  use File::Path;  use File::Path;
20  use Getopt::Long;  use Getopt::Long;
21    
22  my $dump = 0;  my $dump_amv = 0;
23    my $dump_video = 0;
24    my $dump_jpeg = 0;
25    my $dump_audio = 0;
26  my $debug = 0;  my $debug = 0;
27  my $verbose = 0;  my $verbose = 0;
28  my $dump_dir = '/tmp/dump/';  my $dump_dir = '/tmp/dump/';
# Line 28  my $jpeg_q = 100; Line 32  my $jpeg_q = 100;
32  my $jpegtran;  my $jpegtran;
33    
34  GetOptions(  GetOptions(
35          "dump!"                 => \$dump,          "dump-amv!"             => \$dump_amv,
36            "dump-video!"   => \$dump_video,
37            "dump-jpeg!"    => \$dump_jpeg,
38            "dump-audio!"   => \$dump_audio,
39          "debug!"                => \$debug,          "debug!"                => \$debug,
40          "dump-dir=s"    => \$dump_dir,          "dump-dir=s"    => \$dump_dir,
41          "no-jpeg-headers!" => \$no_jpeg_header,          "no-jpeg-headers!" => \$no_jpeg_header,
# Line 53  my $o = 0; Line 60  my $o = 0;
60  my $d;  my $d;
61    
62  sub hex_dump {  sub hex_dump {
         return unless $dump;  
   
63          my ( $bytes, $offset ) = @_;          my ( $bytes, $offset ) = @_;
64          return unless $bytes;          return unless $bytes;
65    
# Line 96  sub x { Line 101  sub x {
101          my $r_len = length($bytes);          my $r_len = length($bytes);
102          confess "read $r_len bytes, expected $len" if $len != $r_len;          confess "read $r_len bytes, expected $len" if $len != $r_len;
103    
104          hex_dump( $bytes );          if ( $dump_amv ) {
105                    print "## raw $len bytes\n";
106                    hex_dump( $bytes );
107            }
108    
109          if ( $bytes eq 'AMV_END_' ) {          if ( $bytes eq 'AMV_END_' ) {
110                  print "> end of file marker AMV_END_\n" if $dump;                  print "> end of file marker AMV_END_\n" if $dump_video;
111                  $d->{eof}++;                  $d->{eof}++;
112                  return;                  return;
113          }          }
# Line 139  sub quality { Line 147  sub quality {
147                  $out .= chr($t);                  $out .= chr($t);
148          }          }
149    
150          if ( $dump ) {          if ( $dump_video ) {
151                  print "## quantization table original\n";                  print "## quantization table original\n";
152                  hex_dump( $in );                  hex_dump( $in );
153                  print "## quantization table for $jpeg_q %\n";                  print "## quantization table for $jpeg_q %\n";
# Line 353  sub mkjpg { Line 361  sub mkjpg {
361                  0,                      # Ah, Ai (not used)                  0,                      # Ah, Ai (not used)
362          );          );
363    
364          if ( $dump ) {          if ( $dump_jpeg ) {
365                  print "## created JPEG header...\n";                  print "## created JPEG header...\n";
366                  hex_dump( $header, 0 );                  hex_dump( $header, 0 );
367          }          }
# Line 465  while ( ! defined($d->{eof}) ) { Line 473  while ( ! defined($d->{eof}) ) {
473    
474                          my $audio_frame = x( $len );                          my $audio_frame = x( $len );
475    
476                            if ( $dump_audio ) {
477                                    printf "#### dumping audio frame %d 0x%x bytes\n", length($audio_frame), length($audio_frame);
478                                    hex_dump( $audio_frame );
479                            }
480    
481                          # remove 8 bytes of something                          # remove 8 bytes of something
482                          $audio_frame = substr( $audio_frame, 8 );                          $audio_frame = substr( $audio_frame, 8 );
483    
# Line 473  while ( ! defined($d->{eof}) ) { Line 486  while ( ! defined($d->{eof}) ) {
486  #                               $audio_frame = substr( $audio_frame, 0, -1 );  #                               $audio_frame = substr( $audio_frame, 0, -1 );
487                          }                          }
488    
                         if ( $dump ) {  
                                 print "#### dumping audio frame ", length($audio_frame), " bytes\n";  
                                 hex_dump( $audio_frame );  
                         }  
   
489  #                       print $audio_fh mp3_frame;  #                       print $audio_fh mp3_frame;
490                          print $audio_fh $audio_frame || die "can't write audio frame in $apath: $!";                          print $audio_fh $audio_frame || die "can't write audio frame in $apath: $!";
491    

Legend:
Removed from v.24  
changed lines
  Added in v.27

  ViewVC Help
Powered by ViewVC 1.1.26