[MEncoder-users] fixing a/v sync
Miroslav Rovis
m.rovis at inet.hr
Sat Jul 14 21:26:17 CEST 2007
I'll start here.
http://www.mplayerhq.hu/DOCS/tech/encoding-tips.txt
(which is mumbo jumbo for non-experts)... Well...
mkfifo and things... Took me time. Didn't get it till I found a working
script (for me) at:
http://linuxwiki.de/MPlayer
I'll paste the script here for clarity:
--------------------------------------
#!/bin/sh
rm -f audiodump.pcm ;
mkfifo -m 600 audiodump.pcm
mplayer [dvd://|vcd://|input-datei] -quiet -vc dummy -vo null -alang
"de" -ao pcm -nowaveheader stream.dump &
oggenc --raw --raw-bits=16 --raw-chan=2 --raw-rate=48000 -q 1 -o
audio-us.ogg audiodump.pcm &
wait
rm -f audiodump.pcm
--------------------------------------
But I need my audio in ac3 if possible, at worst mp3, for backward
compatibiliy, as I burn my videos on DVDs some of which end on very old
equipment for watching...
a/v sync is my common problem. But I am still a little stuck with the
corresponding portion of
http://www.mplayerhq.hu/DOCS/tech/encoding-tips.txt
I tried different ways to dump audio, and I finally found what dumps the
audio from my DVD, losslessly and in sync, to a wav file. It is as
simply as described here:
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-dvd-mpeg4.html
This (modified) line worked for me:
mplayer dvd://1 -dvd-device /dev/hda -ao pcm:file=my_audiodump.wav -vc
null -aid 160 -vo null
The audio finally in sync and in wave file.
What I want to do now is cut it at appropriate places. Namely, the
2:00:00 something video I got, starts in good sync, develops audio delay
of -200ms by 0:05:00, audio delay increases (or decreases) to -500ms by
19:00, at 57:00 reaches -900ms etc.
I am preparing to use dd command for cutting and pasting my dumped file
as there are lengthy voiceover stretches for which the delay makes no
noticeable difference... I will cut out corresponding 200ms first, then
300ms more, then another 300ms etc., and then cat the resulting pieces
together...
(I already tackled this issue, unsuccessfully, see here:
http://www.nabble.com/-Dvdauthor-users--Not-working-exactly-right....-tf2790744.html#a7911637)
What I don't know is how to get the right numbers (read further)... for
48000 rate audio...
Does anyone have similar experiences with this kind of delay?
I earlier tried using different tools for cutting and pasting other
audio stuff from some other videos, and I still haven't gained
sufficient insight nor found proper way to do it...
Here's where I'm stuck at (I'll cite, with _modifications fitting my
case_ that encoding-tips.txt above):
--------------------------------------------------------
...if delay is negative, use a command like this:
( dd if=/dev/zero bs=1764 skip=20 ; cat audiodump.wav ) | cat \
> audiodump_CUT-A-LITTLE-OUT.wav
...change the 1764 number... if your audio stream isn't
44100/16bit/little-endian/stereo
--------------------------------------------------------
The step that I will later be able to check by:
mplayer -v -audiofile audio-dumped_and_edited.wav dvd://1
I added -v here to also tell my knowledgeable readers that for the file
I dumped above I get:
(pasting)
+++++++++++++++++++++++++++++++++++++++++
Searching demuxer type for filename audio-dumped_and_edited.wav ext: .wav
Trying demuxer 17 based on filename extension
==> Found audio stream: 0
======= WAVE Format =======
Format Tag: 1 (0x1)
Channels: 2
Samplerate: 48000
avg byte/sec: 192000
Block align: 4
bits/sample: 16
cbSize: 0
==========================================================================
demux_audio: audio data 0x2C - 0x4EB2002C
Audio file file format detected.
Searching for sequence header... OK!
+++++++++++++++++++++++++++++++++++++++++
(pasted)
What I understand so far is that for the samplerate 48000 I cannot use
bs=1764 as is used for samplerate 44100...
What then should I use, if somebody of you already solved this problem
which many must have encountered?
If I by experimenting find out first, I promise I'll post it here for
all to know!
I also give upfront my apologies here if I messed up for my expert
readers that line from aforementioned tips page... I admit I don't
completely understand, at this time, the line I modified to read:
( dd if=/dev/zero bs=1764 skip=20 ; \
cat audiodump.wav ) | cat > audiodump_aBitShorter.wav
Thanks for the patience,
Miro
www.CroatiaFidelis.hr
www.exDeo.com
More information about the MEncoder-users
mailing list