--- amv.pl 2007/10/01 20:12:50 32 +++ amv.pl 2007/10/02 19:12:07 36 @@ -163,73 +163,6 @@ return $out; } -=for obsolete - -sub mp3_frame { - my $frame = join('', - # Frame sync (all bits set) - 1 x 11 . - # MPEG Audio version ID - # 00 - MPEG Version 2.5 (unofficial) - # 01 - reserved - # 10 - MPEG Version 2 (ISO/IEC 13818-3) - # 11 - MPEG Version 1 (ISO/IEC 11172-3) - 1,0, - # Layer description - # 00 - reserved - # 01 - Layer III - # 10 - Layer II - # 11 - Layer I - 0,1, - # Protection bit - # 0 - Protected by CRC (16bit crc follows header) - # 1 - Not protected - 0, - # Bitrate index - 0,0,0,0, - # Sampling rate frequency index (22050) - 0,0, - # Padding bit - # 0 - frame is not padded - # 1 - frame is padded with one extra slot - 0, - # Private bit - 0, - # Channel Mode - # 00 - Stereo - # 01 - Joint stereo (Stereo) - # 10 - Dual channel (2 mono channels) - # 11 - Single channel (Mono) - 1,1, - # Mode extension (Only if Joint stereo) - 0,0, - # Copyright - 0, - # Original - 0, - # Emphasis - # 00 - none - # 01 - 50/15 ms - # 10 - reserved - # 11 - CCIT J.17 - 0,0, - ); - - die "frame must have 32 bits, not ", length($frame), " for $frame" if length($frame) != 32; - - my $bits = pack("b32", $frame); - - die "packed bits must be 4 bytes, not $bits" if length($bits) != 4; - - my $t = $frame; - $t =~ s/(.{8})/$1 /g; - warn "## mp3 frame frame = $t\n"; - - return $bits; -} - -=cut - my @subframes; my $frame_nr = 1; @@ -499,62 +432,7 @@ $size += 2; } - warn "length isn't corrent $bytes != $size" if $bytes != $size; -} - - -sub x_audio_frame { - my $data = shift || die "no data?"; - - my $apath = sprintf("$dump_dir/%04d.wav", $frame_nr ); - open(my $audio_fh, '>', $apath) || die "can't open audio file $apath: $!"; - - print $audio_fh pack 'a4Va4a4VvvVVv4', ( - # header 'RIFF', size - 'RIFF',-1, - # type: 'WAVE' - 'WAVE', - 'fmt ',0x14, - # format: DVI (IMA) ADPCM Wave Type - 0x11, - # channels - 1, - # samples/sec - 22050, - # avg. bytes/sec (for esimation) - 11567, - # block align (size of block) - 0x800, - # bits per sample (mono data) - 4, - # cbSize (ADPCM with 7 soefficient pairs) - 2, - # nSamplesPerBlock - # (((nBlockAlign - (7 * nChannels)) * 8) / (wBitsPerSample * nChannels)) + 2 - 0x03f9, - ); - - print $audio_fh pack 'a4VVa4V', ( - # time length of the data in samples - 'fact',4, - 220500, - # - 'data',-1, - ); - - my $riff_header_len = tell($audio_fh); - - print $audio_fh $data; - - my $size = tell($audio_fh); - warn "## wav file $apath size: $size\n"; - - seek( $audio_fh, 4, 0 ); - print $audio_fh pack("V", $size - 8); - seek( $audio_fh, $riff_header_len - 4, 0 ); - print $audio_fh pack("V", $size - $riff_header_len); - - close($audio_fh) || die "can't close audio file $apath: $!"; + warn "length isn't corrent $bytes != $size" if $debug && $bytes != $size; } # @@ -658,6 +536,12 @@ } } +if ( $fps == 12 ) { + warn "fixup $au_path for $fps fps -- 16000 Hz\n"; + seek($au_fh, 16, 0); # sample rate offset + print $au_fh pack 'N', 16000; +} + my $cmd = "ffmpeg -r $fps -i $dump_dir/%04d.jpg -i $au_path -y $dump_avi"; system($cmd) == 0 || die "can't convert frames to avi using $cmd: $!";