[MEncoder-users] Audio sync issues

Pierre Grimaud pieroxy at gmail.com
Mon Feb 5 21:52:31 CET 2007


After a little further investigation, it doesn't seem to be a problem with
mkv at all. Here is my new setup:

I ran 'mplayer source.mkv -dumpaudio' and got a stream.dump file
representing my AC3 soundtrack fine. The file is exactly (according to
mplayer) 60.9 seconds long (cf below). I have to say mplayer core dumped
before the end of the dump so only 60.4 seconds are in the file. That may
have something to do with it.

Now I ran an encode without sound which gave me an xvid AVI file which is
exactly (according to mplayer) 60.7 seconds long (1457 frames / 23.976fps =
60.77 secs).

Now I tried to encode these two with the command:
 mencoder -audiofile stream.dump.ac3 transcodedVideo_xvid.avi -o
transcodeVideo_xvid_ac3.avi -ovc copy -oac copy

Everything goes fine up until I try to play the file. At about 10 secs in
the file, the audio is 2 seconds out of sync already !!!!

What am I doing wrong ?

Thanks for the help!





The audio file playback:
----------------------------------------------------------
mplayer stream.dump.ac3
MPlayer 2:0.99+1.0pre8-0ubuntu8 (C) 2000-2006 MPlayer Team
CPU: AMD Sempron(tm) 2500+ (Family: 6, Model: 8, Stepping: 1)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled with runtime CPU detection.


Linux RTC init error in ioctl (rtc_irqp_set 1024): Permission denied
Try adding "echo 1024 > /proc/sys/dev/rtc/max-user-freq" to your system
startup scripts.
Opening joystick device /dev/input/js0
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick
Setting up LIRC support...
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support.
You will not be able to use your remote control.

Playing stream.dump.ac3.
libavformat file format detected.
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
AC3: 5.1 (3f+2r+lfe)  48000 Hz  384.0 kbit/s
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 384.0 kbit/25.00% (ratio: 48000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
alsa-init: using device default
alsa: 48000 Hz/2 channels/4 bpf/65536 bytes buffer/Signed 16 bit Little
Endian
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:  60.4 (01:00.4) of 60.9 (01:00.9)  0.9%
alsa-uninit: pcm closed

Exiting... (End of file)



The video file playback:
----------------------------------------------------------
mplayer transcodeVideo_xvid.avi
MPlayer 2:0.99+1.0pre8-0ubuntu8 (C) 2000-2006 MPlayer Team
CPU: AMD Sempron(tm) 2500+ (Family: 6, Model: 8, Stepping: 1)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled with runtime CPU detection.


Linux RTC init error in ioctl (rtc_irqp_set 1024): Permission denied
Try adding "echo 1024 > /proc/sys/dev/rtc/max-user-freq" to your system
startup scripts.
Opening joystick device /dev/input/js0
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick
Setting up LIRC support...
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support.
You will not be able to use your remote control.

Playing transcodeVideo_xvid.avi.
AVI file format detected.
AVI_NI: No audio stream found -> no sound.
AVI: No audio stream found -> no sound.
VIDEO:  [XVID]  1280x720  12bpp  23.976 fps  998.9 kbps (121.9 kbyte/s)
Clip info:
 Software: MEncoder 2:0.99+1.0pre8-0ubuntu8
open: No such file or directory
Couldn't open: /dev/mga_vid
open: No such file or directory
Couldn't open: /dev/mga_vid
[VO_TDFXFB] Can't open /dev/fb0: Permission denied.
[VO_3DFX] Unable to open /dev/3dfx.
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Audio: no sound
Starting playback...
VDec: vo config request - 1280 x 720 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [xv] 1280x720 => 1280x720 Planar YV12
V:  60.7 1457/1457 19%  0%  0.0% 0 0

Exiting... (End of file)






On 2/5/07, Pierre Grimaud <pieroxy at gmail.com> wrote:
>
> Thanks for your answer, this could explain a lot. And it seems to be
> working !
>
> However, this solution will consistently downsample to stereo whatever
> audio there is in the MKV file. My files contain AC3 sound and I'd like to
> keep it in the encoded file.
>
> Here is what I tried:
>
> mplayer source.avi -dumpaudio
> mencoder -o dest.avi -ovc xvid -nosound source.avi -xvidencopts
> bitrate=3000
> mencoder dest.avi -o final_with_sound.avi -audiofile stream.dump -oac copy
> -ovc copy -fafmttag 0x2000
>
> But I get the sound out of sync... Very depressing. Of course, the
> original file works like a charm !
>
> Any form of help is welcome, of course.
>
> On 2/3/07, Jan Knutar <jknutar at nic.fi> wrote:
> >
> > On Saturday 03 February 2007 00:03, Pierre Grimaud wrote:
> > > I am trying to encode mkv videos (H264/AC3) to XviD AVI, trying to
> >
> > > If I specify "-oac mp3lame", everything works fine (a few duplicate
> > > frames at first and then everything settles down) but in the
> > > resulting video, the audio is out of sync. Anyways, I'd like to be
> > > able to keep the original soundtrack.
> > >
> > > Thanks for any help, much appreciated.
> >
> > mencoder seems to have had some bugs with ogm and mkv for
> > quite some time... Try the following, it sort of works for me, but
> > seems to introduce a smal but constant delay between audio
> > and video:
> >
> > mplayer -ao pcm -novideo file.mkv
> > mencoder -audiofile audiodump.wav file.mkv <rest of options here>
> > _______________________________________________
> > MEncoder-users mailing list
> > MEncoder-users at mplayerhq.hu
> > http://lists.mplayerhq.hu/mailman/listinfo/mencoder-users
> >
>
>
>
> --
> Pierre Grimaud
> 22, rue de Paris
> 78230 Le Pecq, France




-- 
Pierre Grimaud
22, rue de Paris
78230 Le Pecq, France



More information about the MEncoder-users mailing list