Audio sync issues
I am trying to encode mkv videos (H264/AC3) to XviD AVI, trying to preserve the audio track. Whenever I put '-oac copy' in there I have a bunch of lines looking like that: Pos: 0.0s 3f ( 0%) 0.00fps Trem: 0min 0mb A-V:-0.008 [0:0] 1 duplicate frame(s)! Pos: 0.2s 5f ( 0%) 0.00fps Trem: 0min 0mb A-V:-0.017 [0:0] 1 duplicate frame(s)! Pos: 0.9s 22f ( 0%) 19.40fps Trem: 0min 0mb A-V:-0.088 [0:128] 1 duplicate frame(s)! Pos: 1.4s 32f ( 0%) 19.56fps Trem: 0min 0mb A-V:-0.088[1735:128] 1 duplicate frame(s)! Pos: 1.8s 42f ( 0%) 16.98fps Trem: 0min 0mb A-V:-0.088[1884:128] 1 duplicate frame(s)! Pos: 2.2s 52f ( 0%) 15.01fps Trem: 0min 0mb A-V:-0.088[2098:128] 1 duplicate frame(s)! Pos: 2.7s 62f ( 0%) 14.46fps Trem: 0min 0mb A-V:-0.088[2200:128] 1 duplicate frame(s)! Pos: 3.1s 72f ( 0%) 14.04fps Trem: 0min 0mb A-V:-0.088[2433:128] 1 duplicate frame(s)! Which is of course bad (is it ?). When I play the file, usually the audio will get there for a few secs and then will get broken. I tried a '-mc 0' which does make this message disappear, but then I get the following after a few minutes of encoding: Pos: 196.4s 4710f ( 4%) 10.17fps Trem: 177min 1802mb A-V:0.000[3080:128] Too many audio packets in the buffer: (4097 in 6292992 bytes). Maybe you are playing a non-interleaved stream/file or the codec failed? For AVI files, try to force non-interleaved mode with the -ni option. I tried -noskip but the messages are still there (around one for each 10 frames)... "-vf harddup" also shows the same problem (on playback and encoding) 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. -- pieroxy Note: I join one command-line and its output there: =============================== mencoder -o Microcosmos.avi -ovc xvid -oac copy /media/spare/Video/Microcosmos.mkv -xvidencopts bitrate=3000:me_quality=0:vhq=0 -ofps 24000/1001 MEncoder 2:0.99+1.0pre8-0ubuntu8 (C) 2000-2006 MPlayer Team CPU: AMD Sempron(tm) 2500+ (Family: 6, Model: 8, Stepping: 1) CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0 Compiled with runtime CPU detection. success: format: 0 data: 0x0 - 0x16b85337 [mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0 [mkv] Track ID 2: audio (A_AC3), -aid 0, -alang eng [mkv] Will play video track 1 [mkv] Will play audio track 2 Matroska file format detected. VIDEO: [avc1] 1280x720 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s) [V] filefmt:31 fourcc:0x31637661 size:1280x720 fps:23.98 ftime:=0.0417 xvid: using library version 1.1.0 (build xvid-1.1.0) Opening video filter: [expand osd=1] Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1 ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264) ========================================================================== audiocodec: framecopy (format=2000 chans=6 rate=48000 bits=16 B/s=16000 sample-1536) 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. videocodec: XviD (1280x720 fourcc=44495658 [XVID]) xvid: par=0/0 (vga11), displayed=1280x720, sampled=1280x720 xvid: CBR Rate Control -- bitrate=3000kbit/s Writing header... ODML: vprp aspect is 16:9. Setting audio delay to 0.000s. Writing header... ODML: vprp aspect is 16:9. Setting audio delay to 0.000s. Pos: 0.0s 3f ( 0%) 0.00fps Trem: 0min 0mb A-V:-0.008 [0:0] 1 duplicate frame(s)! Pos: 0.2s 5f ( 0%) 0.00fps Trem: 0min 0mb A-V:-0.017 [0:0] 1 duplicate frame(s)! Pos: 0.9s 22f ( 0%) 19.40fps Trem: 0min 0mb A-V:-0.088 [0:128] 1 duplicate frame(s)! Pos: 1.4s 32f ( 0%) 19.56fps Trem: 0min 0mb A-V:-0.088 [1735:128] 1 duplicate frame(s)! Pos: 1.8s 42f ( 0%) 16.98fps Trem: 0min 0mb A-V:-0.088 [1884:128] 1 duplicate frame(s)! Pos: 2.3s 52f ( 0%) 15.99fps Trem: 0min 0mb A-V:-0.088 [2022:128] 1 duplicate frame(s)! Pos: 2.4s 54f ( 0%) 15.82fps Trem: 0min 0mb A-V:-0.054 [2006:128] And another one: =============================== mencoder -o Microcosmos.avi -ovc xvid -oac copy /media/spare/Video/Microcosmos.mkv -xvidencopts bitrate=3000:me_quality=0:vhq=0 -ofps 24000/1001 -mc 0 MEncoder 2:0.99+1.0pre8-0ubuntu8 (C) 2000-2006 MPlayer Team CPU: AMD Sempron(tm) 2500+ (Family: 6, Model: 8, Stepping: 1) CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0 Compiled with runtime CPU detection. success: format: 0 data: 0x0 - 0x16b85337 [mkv] Track ID 1: video (V_MPEG4/ISO/AVC), -vid 0 [mkv] Track ID 2: audio (A_AC3), -aid 0, -alang eng [mkv] Will play video track 1 [mkv] Will play audio track 2 Matroska file format detected. VIDEO: [avc1] 1280x720 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s) [V] filefmt:31 fourcc:0x31637661 size:1280x720 fps:23.98 ftime:=0.0417 xvid: using library version 1.1.0 (build xvid-1.1.0) Opening video filter: [expand osd=1] Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1 ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264) ========================================================================== audiocodec: framecopy (format=2000 chans=6 rate=48000 bits=16 B/s=16000 sample-1536) 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. videocodec: XviD (1280x720 fourcc=44495658 [XVID]) xvid: par=0/0 (vga11), displayed=1280x720, sampled=1280x720 xvid: CBR Rate Control -- bitrate=3000kbit/s Writing header... ODML: vprp aspect is 16:9. Setting audio delay to 0.000s. Writing header... ODML: vprp aspect is 16:9. Setting audio delay to 0.000s. Pos: 0.0s 3f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0] 1 duplicate frame(s)! Pos: 0.2s 5f ( 0%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0] 1 duplicate frame(s)! Pos: 196.4s 4710f ( 4%) 9.59fps Trem: 188min 1802mb A-V:0.000 [3079:128] Too many audio packets in the buffer: (4097 in 6292992 bytes). Maybe you are playing a non-interleaved stream/file or the codec failed? For AVI files, try to force non-interleaved mode with the -ni option. Flushing video frames Writing index... Writing header... ODML: vprp aspect is 16:9. Setting audio delay to 0.000s. Video stream: 3079.551 kbit/s (384943 B/s) size: 75620783 bytes 196.446secs 4710 frames Audio stream: 128.000 kbit/s (15999 B/s) size: 3156480 bytes 197.280secs
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>
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@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@mplayerhq.hu http://lists.mplayerhq.hu/mailman/listinfo/mencoder-users
-- Pierre Grimaud 22, rue de Paris 78230 Le Pecq, France
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@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@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@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
2007/2/5, Pierre Grimaud <pieroxy@gmail.com>:
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 ?
I think this is an mencoder problem. Always I've seen this problem is when there are MANY duplicated frames or dropped frames. Mplayer adjusts the audio position to mantein the sync but mencoder does not, (I think). -- Alejandro Vargas
2007/2/2, Pierre Grimaud <pieroxy@gmail.com>:
I am trying to encode mkv videos (H264/AC3) to XviD AVI, trying to preserve the audio track. Whenever I put '-oac copy' in there I have a bunch of lines looking like that:
I had the same problems when using -oac copy. Try adding -noskip -skiplimit 1 Also -mc 0 could help... -- Alejandro Vargas
participants (3)
-
Alejandro Vargas -
Jan Knutar -
Pierre Grimaud