Log in

View Full Version : A/V sync problems: trying to duplicate audio channel


iliketowatch
13th December 2007, 23:18
I have some video shows that were transferred to DVDs. On some of them, there
is only audio in the right channel. I want to duplicate the right channel to
the left. I have been searching many FAQs and newsgroups and have only come
up with one method (to be described below) that works once in a while. What
I consider not working is when the audio and video are noticeably out of sync.
Sometimes A/V is out of sync by several seconds towards the start of
the video; sometimes just a fraction of a second out of sync towards the end.

I use mplayer to extract the VOB (MPEG-2) from the DVD; this is flawless and has worked fine on all videos:

mplayer -dvd-device DVD-483_484.image -af volnorm dvd://1 -dumpstream -dumpfile AV_483.mpeg


It's easy, using mplayer, to play the video with audio in both channels.
However, if I dump the stream to another file, it is the same as the
original. I also tried mencoder to copy the video and remap the right
channel audio to both channels (sorry, can't find the code I tried) but in
trying to keep the audio ac3, I got avi video.

For the videos with one channel of audio I do the following:
# Extract video
mplayer -cache 8192 AV_483.mpeg -dumpstream -dumpfile /dev/stdout |
tcextract -t vob -a 0 -x mpeg2 > /tmp/TEMP/AV_483.mp2

# Extract audio
# this will save the mono audio as 2 chan. pcm
mplayer -cache 8192 AV_483.mpeg -vc dummy -vo null -channels 1 -ao pcm:file=/tmp/TEMP/AV_483.wav

# Noramlize audio, then encode back to ac3
normalize /tmp/TEMP/AV_483.wav
ffmpeg -i /tmp/TEMP/AV_483.wav -acodec ac3 -ab 384k TEMP/AV_483.ac3

# Merge the two back together
mplex -f 8 -V -o AV_483.mpeg /tmp/TEMP/AV_483.mp2 TEMP/AV_483.ac3


I've tried different -cache settings, faster machines, etc. without any
reliable results. I've also tried sync offsets in mplex, such as
"-O 1501mpt", but again, no reliable results.

Am I missing something here? Should I use different tools?


Here are the versions I used:
---
MPlayer 1.0rc2-3.3.4
CPU: Intel(R) Pentium(R) 4 CPU 3.00GHz (Family: 15, Model: 4, Stepping: 1)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

mjpegtools mplex-2 version 1.8.0 (2.2.4)
ffmpeg version 0.4.9-pre1
tcextract (transcode v1.0.2)
normalize 0.7.6
---

Thanks in advance for any help/insights.

Brian.

nm
14th December 2007, 08:13
Am I missing something here? Should I use different tools?
Try MEncoder again, this time with -of mpeg and take a look at -mpegopts parameters in the manual. Audio can be encoded on the fly with -oac lavc -lavcopts acodec=ac3.

For example, this works for me on PAL MPEG-2 streams:mencoder -dvd-device input.image dvd://1 -ovc copy -oac lavc -lavcopts acodec=ac3:abitrate=192 -af pan=2:1.0:1.0:1.0:1.0,volnorm -of mpeg -o out.mpeg

iliketowatch
14th December 2007, 19:31
Try MEncoder again, this time with -of mpeg and take a look at -mpegopts parameters in the manual. Audio can be encoded on the fly with -oac lavc -lavcopts acodec=ac3.

For example, this works for me on PAL MPEG-2 streams:mencoder -dvd-device input.image dvd://1 -ovc copy -oac lavc -lavcopts acodec=ac3:abitrate=192 -af pan=2:1.0:1.0:1.0:1.0,volnorm -of mpeg -o out.mpeg

It works great. No sync problems in the several I tried. The volnorm filter doesn't seem to work, but perhaps some of the volume levels are over-driven in some of the recordings, leaving some to sound softer.

There are a lot of
ERROR: scr 30.081, dts 0.000, pts 26.825
and
1 duplicate frame(s)!
messages.
However, the videos play fine and no complaints from mplayer.

:thanks:

Thank you very much,
Brian.

iliketowatch
27th December 2007, 18:16
It works great. No sync problems in the several I tried. The volnorm filter doesn't seem to work, but perhaps some of the volume levels are over-driven in some of the recordings, leaving some to sound softer.

However, the videos play fine and no complaints from mplayer.


Upon closer inspection: for the first minute or two, the audio lags the video by 1-3 seconds. It varies from video to video. (Some do not exhibit this problem.) But they get back into sync (in most cases) after a minute or two.

I read a recent post in this forum suggesting the use of "-mc 0 -noskip" for avoiding audio delays. It did not cause a difference of delay. I also added the "-forceidx" with no change.
The line I used to encode:

mencoder -dvd-device input.image dvd://1 -mc 0 -noskip -ovc -forceidx copy -oac lavc -lavcopts acodec=ac3:abitrate=192 -af pan=2:1.0:1.0:1.0:1.0,volnorm -of mpeg -o out.mpeg

I looked into multi-pass methods, but (correct me if I'm wrong) this appears to just apply to rencoding the video; which is just being copied through in this case.

Any ideas? I'll keep reading through the man pages.
Is there a way with ffmpeg?

Thanks,
Brian.

iliketowatch
27th December 2007, 23:48
Upon closer inspection: for the first minute or two, the audio lags the video by 1-3 seconds. It varies from video to video. (Some do not exhibit this problem.) But they get back into sync (in most cases) after a minute or two.

I read a recent post in this forum suggesting the use of "-mc 0 -noskip" for avoiding audio delays. It did not cause a difference of delay. I also added the "-forceidx" with no change.
The line I used to encode:

mencoder -dvd-device input.image dvd://1 -mc 0 -noskip -ovc -forceidx copy -oac lavc -lavcopts acodec=ac3:abitrate=192 -af pan=2:1.0:1.0:1.0:1.0,volnorm -of mpeg -o out.mpeg

I looked into multi-pass methods, but (correct me if I'm wrong) this appears to just apply to rencoding the video; which is just being copied through in this case.

Any ideas? I'll keep reading through the man pages.
Is there a way with ffmpeg?


By using "-mc 1" it syncs right away:

mencoder -dvd-device input.image dvd://1 -mc 1 -noskip -ovc -forceidx copy -oac lavc -lavcopts acodec=ac3:abitrate=192 -af pan=2:1.0:1.0:1.0:1.0,volnorm -of mpeg -o out.mpeg