[MPlayer-users] Re: audio sync -- the final step between me and happiness.

Noah Spurrier noah at noah.org
Wed Jun 14 07:56:04 CEST 2006


> From: Dominik 'Rathann' Mierzejewski <dominik at rangers.eu.org>
> To: mplayer-users at mplayerhq.hu
> >
> Why not encode audio while encoding video? You should use -aid 129 in
mencoder
> command line, too.

All of the tutorials I have read for ripping DVDs say to compress the audio
separately. I'm not even sure how to encode the audio while also encoding
the video.

I added -aid 129 to my transcoding steps so I ended up with a
videodump.avi as
an MPEG4 video with the original AC3 audio stream. The movie looks and sounds
good. The audio is in sync. But the audio is too big. I checked the
videodump.avi and it has only one audio stream (I checked that it's the
correct
one) After transcoding Mencoder shows it now as AID 1 (ID_AUDIO_ID=1) instead
of 129. I checked my MP3 compressed audio stream and it sounds good. It seems
to be exactly the same as the AC3 audio stream (AID=1) in videodump.avi. Now
all I need to do is replace the AC3 audio in videodump.avi with the MP3 audio
stream. I used the following command to copy the video with the new MP3 audio
stream. This produces a video with the audio out of sync.

    mencoder -oac copy -ovc copy -o video_final.avi -audiofile
audiodump.mp3 videodump.avi
# Note:
# videodump.avi contains an MPEG4 video and AC3 audio in sync.
# audiodump.mp3 is the same audio track as the AC3 audio, but in MP3 format.
# video_final.avi contains the MPEG4 video and MP3 audio format, but OUT
OF SYNC.

I'm not sure how mencoder's audio sync algorithm works. Maybe I am not
enabling
it. Or maybe I am doing something wrong to make it unable to sync. How does
mencoder sync a source video and AC3 audio stream with a new MP3 audio
stream?
Does mencoder actually listen to the original audio stream and the drop or
pad
video frames to make it sync with the replacement audio stream?

> I don't believe you should automate it. There are all sorts of
source-dependent
> settings to consider, like cropping, telecine, ofps and such. If you
disregard
> that, you'll get lower quality at best, completely messed up encode at
worst.

I should not have said totally automatic. My scripts asks a few questions
such
as which audio channel you want; if the video is black-and-white or
cartoon; or
interlaced. The script automatically detects cropping (it checks for 30
seconds
in 10 different places in the video and picks the most common crop
suggestion).
The script is in Python. It's pretty smart except for the audio sync :-( I
can
save nearly 100 MB by replacing the AC3 audio with MP3 at 96 Kbps. If only I
could figure out the sync problem...

Yours,
Noah





More information about the MPlayer-users mailing list