[MEncoder-users] a/v desync with mencoder that doesn't happen with mplayer -dumpstream

L. Lee llee040 at sbcglobal.net
Tue Nov 29 20:09:30 CET 2011


I recently submitted this suggestion for adjusting a/v sync using ffmpeg.
I've discovered that all the included examples caused the audio to be
advanced, although the first example incorrectly claims to provide delay for
the audio. I discovered that to apply delay to the audio, a minus (-) must
also precede the numeric value, so the first example should read:

"Make audio 3 seconds later:
ffmpeg -i input.flv -itsoffset -00:00:03.0 -i input.flv -vcodec copy -acodec
copy -map 1:0 -map 0:1 output_shift3s-delay.flv"

I haven't tested to determine whether the order of the "-map" options must
be reversed between the first and second examples as indicated.

Anybody know?

Anyway, to summarize, if the minus (-) before the numeric value is omitted,
both the original examples serve to advance the audio for the files I've
tested.

Thanks.

Laine


On 11/8/11 1:27 PM, "L. Lee" <llee040 at sbcglobal.net> wrote:

> I occasionally have to deal with a stream for which audio seems to begin
> before video, and MPlayer appears to maintain sync by starting playback at the
> point where video enters. When transcoding with MEncoder, I found that I had
> to disable  -noskip to allow black frames to be created before entrance of the
> video so that sync was maintained. That caused some issues that made me change
> other options, because I'm having to perform pullup with encoding, but it
> might be worth trying.
> 
> Also, because I have to build ffmpeg to build MEncoder now, it's always
> available. You can use ffmpeg to offset the sync so you can tell whether the
> duration is correct. Here are examples (from
> http://lzone.de/fix+async+video+with+ffmpeg)
> 
> Make audio 3 seconds later:
> ffmpeg -i input.flv -itsoffset 00:00:03.0 -i input.flv -vcodec copy -acodec
> copy -map 1:0 -map 0:1 output_shift3s-delay.flv
> 
> Make audio 3 seconds earlier:
> ffmpeg -i input.flv -itsoffset 00:00:03.0 -i input.flv -vcodec copy -acodec
> copy -map 0:1 -map 1:0 output_shift3s-advance.flv
> 
> Here's an example for making an iPad (or iPhone) movie's audio about 300
> milliseconds earlier:
> 
> ffmpeg -i inputmovie.iPad.mp4 -itsoffset 00:00:00.3 -i inputmovie.iPad.mp4
> -vcodec copy -acodec copy -map 1:0 -map 0:1 outputmovie.iPad.300ms-advance.mp4
> 
> Laine Lee
> 
> 
> On 11/7/11 10:23 PM, "Brion Swanson" <deadbeefb5 at gmail.com> wrote:
> 
>> On 11/05/2011 08:14 PM, The Wanderer wrote:
>>> On 11/05/2011 01:37 PM, Brion Swanson wrote:
>>> 
>>>> On 11/04/2011 09:33 AM, The Wanderer wrote:
>>> 
>>>>> Is the size of the desync consistent within any given rip, or does
>>>>> it vary
>>>>> over time as you let the movie play?
>>>> 
>>>> It appears consistent but since it's so far off it's hard to tell for
>>>> sure if
>>>> it's getting farther apart or not.
>>> 
>>> Yeah, that would be a bit tricky.
>>> 
>>> Does the MPlayer status line report the difference (in the 'A-V:'
>>> value), or
>>> does that claim to be in sync? If it does show the difference there,
>>> then you
>>> could use that to judge whether the desync is varying or not.
>>> 
>>>>> Do you get the same desync with e.g. ffplay?
>>>> 
>>>> I'm not sure how to use ffplay to play the DVD directly, but if I
>>>> play the
>>>> stream.dump file there is no desync (though there is no desync in
>>>> mplayer
>>>> with that file either).
>>> 
>>> I meant, do you get the desync when you play the transcoded file using
>>> ffplay?
>>> 
>>> You've answered this in another response. That rules out one
>>> possibility, or at
>>> least makes it less likely; I've seen at least one case where MPlayer
>>> got the
>>> frame rate wrong on a particular VFR file (which had apparently been
>>> created
>>> using MEncoder), but ffplay could handle it just fine.
>>> 
>>> (I really should get around to putting together a formal report about
>>> that.)
>>> 
>>> Unfortunately, off the top of my head I don't have anything else to
>>> suggest,
>>> aside from perhaps posting a full console log of at least a playback
>>> session and
>>> possibly even the actual encoding process. There's no guarantee anyone
>>> would be
>>> able to help based on that, but it could hardly hurt... though the
>>> encoding log
>>> would probably be excessively large.
>>> 
>> Poking around some more on this I found out a few interesting facts:
>> 
>> 1. specifying -ofps 24000/1001 caused the audio to out of sync behind
>> the video instead of in front of it
>> 2. specifying -ofps 30000/1001 caused the audio to be very much behind
>> the video
>> 3. Benchmarking the video without audio (-nosound) did not result in
>> errors although allowing the video gave a VC% of about 52% while -vo
>> null gave a VC% of about 92% -- I don't know if that's usual or expected
>> 4. Playing the video does not produce any significant errors (just a
>> couple changes from soft telecine (24000/1) to hard telecine
>> (30000/1001) and back
>> 5. I tried doing a normal transcoding (instead of -oac copy and -ovc
>> copy) and the audio delay was still there (though the video quality was
>> considerably lower) and with the same amount of delay
>> 6. There was nothing special in the encoding log that I haven't already
>> mentioned even when I let it complete.
>> 
>> Any other ideas you guys might have is appreciated.  This is truly
>> baffling to me.
>> 
>> Here's my OS info:
>> 
>> brion at lightyear:~$ lsb_release -a
>> No LSB modules are available.
>> Distributor ID:    Ubuntu
>> Description:    Ubuntu 11.10
>> Release:    11.10
>> Codename:    oneiric
>> 
>> Here's the output of playing the video straight from the DVD (has no
>> audio issues):
>> 
>> brion at lightyear:~$ mplayer -v dvd://44 -forcedsubsonly
>> mplayer: Symbol `ff_codec_bmp_tags' has different size in shared object,
>> consider re-linking
>> MPlayer SVN-r33713-4.6.1 (C) 2000-2011 MPlayer Team
>> CPU vendor name: GenuineIntel  max cpuid level: 10
>> CPU: Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz (Family: 6, Model:
>> 15, Stepping: 11)
>> extended cpuid-level: 8
>> extended cache-info: 268468288
>> Detected cache-line size is 64 bytes
>> CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNowExt: 0 SSE: 1 SSE2: 1 SSSE3: 1
>> Compiled with runtime CPU detection.
>> get_path('codecs.conf') -> '/home/brion/.mplayer/codecs.conf'
>> Reading /home/brion/.mplayer/codecs.conf: Can't open
>> '/home/brion/.mplayer/codecs.conf': No such file or directory
>> Reading /etc/mplayer/codecs.conf: Can't open '/etc/mplayer/codecs.conf':
>> No such file or directory
>> Using built-in default codecs.conf.
>> init_freetype
>> Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay
>> get_path('fonts') -> '/home/brion/.mplayer/fonts'
>> Configuration: --prefix=/usr --confdir=/etc/mplayer --enable-xvmc
>> --enable-menu --disable-arts --language=all --disable-libdvdcss-internal
>> --disable-dvdread-internal --disable-ffmpeg_a --enable-joystick
>> --enable-runtime-cpudetection --enable-debug --enable-mga --enable-3dfx
>> --enable-tdfxfb --disable-gui
>> CommandLine: '-v' 'dvd://44' '-forcedsubsonly'
>> Using nanosleep() timing
>> get_path('input.conf') -> '/home/brion/.mplayer/input.conf'
>> Can't open input config file /home/brion/.mplayer/input.conf: No such
>> file or directory
>> Parsing input config file /etc/mplayer/input.conf
>> Input config file /etc/mplayer/input.conf parsed: 92 binds
>> 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.
>> get_path('44.conf') -> '/home/brion/.mplayer/44.conf'
>> 
>> Playing dvd://44.
>> get_path('sub/') -> '/home/brion/.mplayer/sub/'
>> URL: dvd://44
>> libdvdread: Using libdvdcss version 1.2.10 for DVD access
>> Reading disc structure, please wait...
>> There are 99 titles on this DVD.
>> There are 1 angles in this DVD title.
>> 
>> libdvdread: Attempting to retrieve all CSS keys
>> libdvdread: This can take a _long_ time, please be patient
>> 
>> libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x00006a12
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_01_0.VOB at 0x00006ca7
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_01_1.VOB at 0x000071e7
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_02_0.VOB at 0x00007209
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_02_1.VOB at 0x0000728c
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_03_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_03_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_04_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_04_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_05_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_05_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_06_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_06_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_07_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_07_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_08_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_08_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_09_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_09_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_10_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_10_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_11_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_11_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_12_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_12_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_13_0.VOB at 0x0000757e
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_13_1.VOB at 0x0000f2b8
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_14_0.VOB at 0x001efdb0
>> libdvdread: Elapsed time 0
>> libdvdread: Get key for /VIDEO_TS/VTS_14_1.VOB at 0x001f2425
>> libdvdread: Elapsed time 0
>> libdvdread: Found 14 VTS's
>> libdvdread: Elapsed time 0
>> 
>> DVD successfully opened.
>> audio stream: 0 format: ac3 (5.1) language: en aid: 128.
>> number of audio channels on disk: 1.
>> subtitle ( sid ): 1 language: en
>> subtitle ( sid ): 3 language: fr
>> subtitle ( sid ): 5 language: es
>> subtitle ( sid ): 7 language: pt
>> number of subtitles on disk: 4
>> 
>> DVD start cell: 0  pack: 0x1010-0x2432
>> DVD start=4112 end=1968350
>> STREAM: [null] dvd://44
>> STREAM: Description: DVD stream
>> STREAM: Author:
>> STREAM: Comment:
>> DVD Seek! lba=0x1010  cell=0  packs: 0x1010-0x2432
>> Angle-seek synced by cell/vob IDN search!
>> system stream synced at 0x80800D (8421389)!
>> ==> Found video stream: 0
>> MPEG-PS file format detected.
>> ==> Found subtitle: 0
>> ==> Found subtitle: 1
>> ==> Found subtitle: 2
>> ==> Found subtitle: 3
>> ==> Found subtitle: 4
>> ==> Found subtitle: 5
>> ==> Found subtitle: 6
>> ==> Found subtitle: 7
>> ==> Found audio stream: 128
>> Searching for sequence header... OK!
>> VIDEO:  MPEG2  720x480  (aspect 3)  29.970 fps  9800.0 kbps (1225.0 kbyte/s)
>> [V] filefmt:2  fourcc:0x10000002  size:720x480  fps:29.970  ftime:=0.0334
>> get_path('sub/') -> '/home/brion/.mplayer/sub/'
>> open: No such file or directory
>> [MGA] Couldn't open: /dev/mga_vid
>> open: No such file or directory
>> [MGA] Couldn't open: /dev/mga_vid
>> [VO_TDFXFB] Can't open /dev/fb0: Permission denied.
>> [VO_3DFX] Unable to open /dev/3dfx.
>> X11 opening display: :0
>> vo: X11 color mask:  FFFFFF  (R:FF0000 G:FF00 B:FF)
>> vo: X11 running at 3600x1080 with depth 24 and 32 bpp (":0" => local
>> display)
>> [x11] Detected wm supports NetWM.
>> [x11] Detected wm supports FULLSCREEN state.
>> [x11] Detected wm supports ABOVE state.
>> [x11] Detected wm supports BELOW state.
>> [x11] Current fstype setting honours FULLSCREEN ABOVE BELOW X atoms
>> Disabling DPMS
>> DPMSDisable stat: 1
>> ==========================================================================
>> Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
>> INFO: libavcodec init OK!
>> Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2)
>> ==========================================================================
>> ==========================================================================
>> Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
>> dec_audio: Allocating 192000 + 65536 = 257536 bytes for output buffer.
>> FFmpeg's libavcodec audio codec
>> INFO: libavcodec "ac3" init OK!
>> AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000)
>> Selected audio codec: [ffac3] afm: ffmpeg (FFmpeg AC-3)
>> ==========================================================================
>> Building audio filter chain for 48000Hz/2ch/s16le -> 0Hz/0ch/??...
>> [libaf] Adding filter dummy
>> [dummy] Was reinitialized: 48000Hz/2ch/s16le
>> [dummy] Was reinitialized: 48000Hz/2ch/s16le
>> Trying preferred audio driver 'pulse', options '[none]'
>> AO: [pulse] 48000Hz 2ch s16le (2 bytes per sample)
>> AO: Description: PulseAudio audio output
>> AO: Author: Lennart Poettering
>> Building audio filter chain for 48000Hz/2ch/s16le -> 48000Hz/2ch/s16le...
>> [dummy] Was reinitialized: 48000Hz/2ch/s16le
>> [dummy] Was reinitialized: 48000Hz/2ch/s16le
>> Starting playback...
>> Increasing filtered audio buffer size from 0 to 50048
>> Unsupported PixelFormat 61
>> Unsupported PixelFormat 53
>> [ffmpeg] aspect_ratio: 1.777778
>> VDec: vo config request - 720 x 480 (preferred colorspace: Planar YV12)
>> Trying filter chain: vo
>> VDec: using Planar YV12 as output csp (no 0)
>> Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
>> VO Config (720x480->854x480,flags=0,'MPlayer',0x32315659)
>> VO: [vdpau] 720x480 => 854x480 Planar YV12
>> VO: Description: VDPAU with X11
>> VO: Author: Rajib Mahapatra <rmahapatra at nvidia.com> and others
>> [vdpau] Updating CSC matrix for BT.601
>> *** [vo] Allocating mp_image_t, 720x480x12bpp YUV planar, 518400 bytes
>> [mpeg2video @ 0x7fa4ed8404c0]qscale == 0
>> [mpeg2video @ 0x7fa4ed8404c0]Warning MVs not available
>> [mpeg2video @ 0x7fa4ed8404c0]concealing 1035 DC, 1035 AC, 1035 MV errors
>> DVD sub: len=66  v_pts=0.033  s_pts=0.183  ts=16483
>> *** [vo] Allocating mp_image_t, 720x480x12bpp YUV planar, 518400 bytes
>> Unicode font: 5179 glyphs.
>> Unicode font: 5179 glyphs.
>> A:   0.5 V:   0.2 A-V:  0.246 ct:  0.003   3/  3 ??% ??% ??,?% 2 0
>> *** [vo] Allocating mp_image_t, 720x480x12bpp YUV planar, 518400 bytes
>> A:   0.6 V:   0.6 A-V:  0.008 ct:  0.014  13/ 11 ??% ??% ??,?% 4 0
>> 
>> demux_mpg: 24000/1001fps progressive NTSC content detected, switching
>> framerate.
>> A:   1.9 V:   1.9 A-V:  0.001 ct:  0.032  45/ 42 10%  7%  0.7% 4 0
>> _______________________________________________
>> MEncoder-users mailing list
>> MEncoder-users at mplayerhq.hu
>> https://lists.mplayerhq.hu/mailman/listinfo/mencoder-users




More information about the MEncoder-users mailing list