#!/bin/sh # # remultiplex an mpg file # be carefull about possible sound synchonization. # def_format=8 help(){ cat < Option: -f n Output type 1=vcd, 4=svcd, 8=dvd ($def_format) -h Print this help message END exit 0 } format=$def_format while getopts f:h name "$@" do case $name in f) format=$OPTARG ;; *) help ;; esac done let shiftind=$OPTIND-1 shift $shiftind case $format in 8) astream=0xBD,0x80 ;; *) astream=0xC0,0x00 ;; esac if test "$#" != "1" then help exit fi case $1 in *.mpg) input="$1" base=`echo $input | sed "s/\.mpg$//"` ;; *) help ;; esac echo Remultiplexing $input.... sleep 1 soff=`tcprobe -i $input | tail -1 | awk '{ print $2/29.97 + $4/1000 }'` echo ...offset is $soff seconds... sleep 1 #tcdemux -x mpeg2 -i $input >$base.m2v #tcdemux -x ac3 -i $input >$base.m2a #extract_mpeg2 $input >$base.m2v #mplayer $input -dumpfile temp-$$.m2a -dumpaudio mplayer $input -dumpfile $base.m2v -dumpvideo #mplayer $input -dumpfile $base.m2a -dumpaudio #mplayer -vc dummy -vo null -ao pcm t003.mpg #mplayer -vo null -ao pcm t003.mpg #toolame audiodump.wav $base.m2a #extract_a52 $input | a52dec -o wav | toolame /dev/stdin $base.m2a #toolame t002.wav $base.m2a #mencoder $input -oac pcm -ovc frameno -o temp-$$.wav mplayer $input -vc dummy -vo null -ao pcm -aofile temp-$$.wav #mplayer t002.mpg -vo null -oa pcm #toolame t002.wav $base.m2a #tcmplex -m d -i $base.m2v -p $base.m2a -o $base-re.mpg #mpegcat -w temp-$$.m2a,0xC0,0x00 -w $base.m2v,0xE0,0x00 $input >/dev/null #echo mpegcat -D -w temp-$$.m2a,$astream -w $base.m2v,0xE0,0x00 $input #mpegcat -D -w temp-$$.m2a,$astream -w $base.m2v,0xE0,0x00 $input >/dev/null #findmpg temp-$$.m2a $base.m2a #mpg123 -s temp-$$.m2a | toolame /dev/stdin $base.m2a #mpg123 -s temp-$$.m2a | mp2enc -r48000 -o $base.m2a mp2enc -r48000 -o $base.m2a