[MPlayer-users] mkv to divx audio sync issues

Wes Morgan morganw at chemikals.org
Sun Nov 25 22:48:45 CET 2007


On Sun, 25 Nov 2007, Bart de Boer wrote:

> Nico Sabbi wrote:
>> Il Saturday 24 November 2007 12:25:17 Bart de Boer ha scritto:
>>
>>> Dear mplayer people,
>>>
>>> Sorry if I'm double-posting. I think something went wrong with my
>>> previous post. So here I go (again):
>>>
>>> I have a P4 2.8Ghz Celeron that isn't powerful enough to decode my
>>> 720p H.264 mkv's. So I'm using mencoder to convert them to MPEG4
>>> Divx. This works nicely performancewise. They only take up around
>>> 30% CPU to decode on that machine now. :)
>>>
>>> I am however having another issue. There always seems to be a
>>> slight A/V sync problem. (The original mkv's run perfectly in
>>> sync.) I tried different mkv's. I also tried numerous parameters
>>> without success. One thing that seemed to work (in most cases) is
>>> to seek 1 second into the video using -ss 0:00:01 and start
>>> converting from there. Therefore I conclude something goes wrong at
>>> the beginning few frames of the video.
>>>
>>> These are the commands I'm currently using:
>>>
>>> mencoder ${inputFile} -ss 0:00:01 -oac copy -nosound -mc 0 -noskip
>>> -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:turbo:vpass=1
>>> -passlogfile ${logFile} -o /dev/null
>>>
>>> mencoder ${inputFile} -ss 0:00:01 -oac copy -mc 0 -noskip -ovc lavc
>>> -lavcopts vcodec=mpeg4:mbd=2:trell:v4mv:vbitrate=4000:vpass=2
>>> -passlogfile ${logFile} -o $outputFile
>>>
>>> Is this an issue with mencoder or am I using the wrong method?
>>>
>>
>> copying one or more of the streams with -mc 0 -noskip is generally
>> a recipe for disaster. remove -mc 0 -noskip and try also -demuxer lavf
>>
>
> Well, I removed -mc 0 and -noskip and added -demuxer lavf... But that
> gave me all sorts of "duplicate frame" errors and finally completely
> failed with: "Too many audio packets in the buffer:"
>
> Removing -demuxer lavf works without errors but that leaves me back to
> square one... I guess seeking into the video for 1 second helps... But
> that seems a bit of a workaround... It looks like mencoder is
> encountering "duplicate frames" and then failing to keep A/V sync after
> that?...
>
> I'm using the backported mplayer-1.0~rc2 under Ubuntu by the way...

I've struggled with this problem myself... On both rc1 and rc2. I think I 
got it to work very well once, but I can't remember what I did. However, 
over the last couple days I've been trying to do another conversion and 
what I noticed was this --

1) The .mkv plays in perfect sync.
2) If I extract (with mkvtools) the audio track and play it, it is
    significantly shorter than the video. On the order of 15 minutes!
3) If I dump the audio with -dumpaudio, I still get the "short" audio
4) If I transcode the video with "-oac copy", the audio sync is horrible
5) If I transcode with "-oac mp3lame", the sync is *almost* perfect, maybe
    a half-second or less off
6) If I dump the audio to a pcm/wav file, encode it to ac3 with ffmpeg
    (ffmpeg -i file.wav -r 23.976 -ab 448k -acodec ac3 file.ac3), then
    use avimerge to remux it into a new file, the sync looks damn good.

The mencoder command line I use is basically:

mencoder -oac mp3lame -ovc lavc -ffourcc XVID -ofps 24000/1001 \
   -passlogfile mpeg4enc.log -msglevel all=-1:statusline=5 \
   -lavcopts vbitrate=2000:last_pred=2:mbd=2:turbo:naq:qpel:trell:subq=6:autoaspect=1:v4mv:threads=2:vpass=1
   -o file.avi input.mkv




More information about the MPlayer-users mailing list