I'm crossposting this message because i am not sure where the problem
is. It could be with tcprobe, it could be with mplex.

I am using transcode-0.6.14, mjpegtools-1.6.2 and dvdauthor-0.6.11 to
backup a DVD title to a blank DVD. I will describe the method, then i
will point out the problem. I apologize for the long message, but i have
to describe in detail how to reproduce the problem (it's pretty subtle).

Insert the source DVD into the unit.
Setup some variables first:

proj="some_dvd"
dev="/dev/dvd"
mkdir $proj
cd $proj

Count the number of titles on the source DVD:

nt=`tcprobe -H 10 -i ${dev} 2>&1 | \
        grep "DVD title" | \
        cut -d : -f 1 | \
        cut -d / -f 2`
echo $nt

Print each title's parameters in a human-readable form:

for i in `seq 1 ${nt}`; do
        len=`tcprobe -T ${i} -H 10 -i ${dev} 2>&1 | \
                grep "playback time" | \
                cut -d : -f 2-`
        nc=`tcprobe -T ${i} -H 10 -i ${dev} 2>&1 | \
                grep "DVD title" | \
                cut -d : -f 2 | \
                cut -d c -f 1`
        ang=`tcprobe -T ${i} -H 10 -i ${dev} 2>&1 | \
                grep "DVD title" | \
                cut -d , -f 2 | \
                cut -d a -f 1`
        echo -n "Title ${i}:"
        echo -n -e "\t"
        echo -n "${nc}chapters"
        echo -n -e "\t"
        echo -n "${ang}angles"
        echo -n -e "\t"
        echo ${len}
        max=${i}
done

Verify, e.g., title #1 to make sure it's the one we want:

xine dvd:/1

Choose e.g. title #1 for saving:

n=1

Actually save the title:

tccat -i ${dev} -t dvd -T ${n},-1 -L > ${proj}.vob

Also save the chapter timestamps:

for ch in `tcprobe -T ${n} -H 10 -i $dev 2>&1 | \
                grep Chapter | \
                cut -d ] -f 2 | \
                cut -c 2-13`; do
        echo -n ${ch} >> chap-temp.txt
        echo -n "," >> chap-temp.txt
done
i=`wc -m chap-temp.txt | cut -f 1 -d c`
i=$[ $i - 1 ]
cat chap-temp.txt | cut -c 1-${i} > chapters.txt
rm -f chap-temp.txt
cat chapters.txt

Extract audio/video tracks info:

tcprobe -T ${n} -H 10 -i $dev 2>/dev/null | \
        grep dvd_reader.c | \
        cut -d \) -f 2 | \
        cut -c 2- > title-${n}-tracks.txt
cat title-${n}-tracks.txt

Extract time alignment info:

tcprobe -H 500 -i ${proj}.vob > title-${n}-pts.txt
cat title-${n}-pts.txt

PLEASE NOTE:
The command above is one of the suspects. It displays the PTS of each
track. If the PTS of the video track and the PTS of the chosen audio
track are different, the difference will be used later with mplex to mux
back the tracks. If tcprobe does not deduce the right value,
misalignment might occur (and it does occur under some circumstances,
just keep reading).

Based on the last two tcprobe commands, choose an audio track:

aud=0

Extract the video track and the chosen audio track:

mv $proj.vob $proj-big.vob
mkfifo vid.fifo
mkfifo aud.fifo
tcextract -i vid.fifo -t vob -x mpeg2 -a 0xe0 > ${proj}.m2v &
tcextract -i aud.fifo -t vob -x ac3 -a ${aud} > ${proj}.ac3 &
cat $proj-big.vob | tee vid.fifo aud.fifo > /dev/null

Compute total audio+video size:

vsize=`ls -l ${proj}.m2v | \
        awk '{print $5}'`
vsize=`echo $vsize / 1048576 | bc`
asize=`ls -l ${proj}.ac3 | \
        awk '{print $5}'`
asize=`echo $asize / 1048576 | bc`
echo "$vsize + $asize" | bc

If larger than 4400MB, the video track must be requantized.
Compute the requant factor:

req=`echo "1.05 * $vsize / (4400 - $asize)" | bc -ql`
echo $req

Requantize if $req > 1.0:

mv $proj.m2v $proj-big.m2v
tcrequant -i $proj-big.m2v -o $proj.m2v -f $req

Look again at title-${n}-pts.txt - if the PTS of the video track and the
PTS of the audio track are different, compute the difference (videoPTS -
audioPTS) and multiply it by 1000. Append "ms" to the result and store
it in the $diff variable. E.g.:

diff=91ms

Remux audio and video; if there is no $diff (equal PTS) then skip the -O
parameter:

mplex -f 8 -S 4400 -O $diff $proj.m2v $proj.ac3 -o $proj.vob

PLEASE NOTE:
The command above is the second suspect. mplex is aligning the tracks
based on what tcprobe deduced from the saved title. If either tcprobe or
mplex are wrong, the result will be wrong.

Re-author a DVD image:

dvdauthor -o ${proj} -c `cat chapters.txt` ${proj}.vob
dvdauthor -T -o ${proj}


Now here is the actual problem:
Find a DVD where the PTS difference between video and audio is larger
than 200ms. Then go through the steps above.
The result will be a DVD with video and audio not in sync!

For PTS differences smaller than approx. 100, it works very well. For
diffs larger than 200 it typically produces misaligned tracks.

Where is the problem? tcprobe? mplex?

-- 
Florin Andrei

http://florin.myip.org/



-------------------------------------------------------
This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005
Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows
Embedded(r) & Windows Mobile(tm) platforms, applications & content.  Register
by 3/29 & save $300 http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click
_______________________________________________
Mjpeg-users mailing list
Mjpeg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mjpeg-users

Reply via email to