[MEncoder-users] At wit's end - MEncoder can't keep AV sync, others can

Wes Morgan morganw at chemikals.org
Sun May 23 16:28:11 CEST 2010

On Thu, 20 May 2010, Steve West wrote:

> Pulling my hair out over this one.  Simply cannot make MEncoder maintain
> audio/ video sync with a certain video that numerous other programs play
> AND transcode correctly.  Hoping the experts here might help: and
> possibly, this may even be a MEncoder bug, so, another reason to bring
> it up here.
> Source material is a VOB from a DVD+RW recorded in a Pioneer set-top DVD
> recorder from American 525i (480i) NTSC VHS.
> All the following leave me with proper A/V sync:
> * That .VOB played with VLC 1.0.5
> * That .VOB played with Gabest's Media Player Classic
> * That .VOB played in MPlayer for Windows (r31027 from http://mulder.at.gg/)
> * That .VOB converted to an XviD+MP3 .avi with AutoGK 2.55
> * That .VOB converted to an x264+AAC .mp4 with Womble MPEG Video Wizard DVD 5.0
> All the following leave me with broken A/V sync with audible skipping:
> * That .VOB converted to an x264+MP3 .avi with MEncoder r31139 (from http://oss.netfarm.it/)
> The command line I started off with:
> mencoder.exe input.vob -ofps 29.97 -vf scale=640:480,denoise3d,softskip,harddup -nosound -ovc x264 -x264encopts bitrate=1200:pass=1 -o nul
> mencoder.exe input.vob -ofps 29.97 -vf scale=640:480,denoise3d,softskip,harddup -af volnorm=1 -oac mp3lame -lameopts abr:br=192 -srate 32000 -ovc x264 -x264encopts bitrate=1200:pass=2 -o output.avi
> When that failed, I RTFM and wound up trying (with absolutely no luck) all the
> following changes to the commandlines above, one at a time (i.e. each change was
> undone before the next was tried):
> * Replacing -nosound on pass1 cmdline with same audio params from pass2 cmdline
> * -ofps 30000/1001 instead of -ofps 29.97
> * Omitting -ofps entirely
> * Adding -mc 0 -noskip -skiplimit 0, and :force_cfr: to x264encopts
> * Adding just force_cfr to x264encopts
> * Adding just -mc 0 -noskip
> * Adding just -noskip
> * Removing softskip
> * Removing harddup
> * Removing denoise3d
> Nothing worked.  Same bad sync and audible skipping as before, only sometimes with
> the A/V sync even worse.
> So I went back to my original command lines as seen above, and decided to try
> feeding MEncoder different input -- by (one at a time):
> * Opening my .VOB and re-saving (stream copy) as .MPG with Womble (this strips all
>   VOB internals and yields "pure" MPEG-2 PS file); MEncoder still produced .avi
>   with broken AV sync+skipping from this.
>   * Opening above .MPG in VideoRedo TVSuite, running it through QuickStream Fix
>     into yet another new .MPG; MEncoder still produced .avi with broken AV
>     sync+skipping from this.
> * Converting my .VOB to MPEG transport stream with ProjectX; MEncoder still
>   produced .avi with broken AV sync+skipping from this.
> * Demuxing my .VOB to .mpv and .ac3 elementary streams with Womble and remuxing
>   those (with Womble again) to a fresh .MPG file.  MEncoder still produced
>   .avi with broken AV sync+skipping from this.
> * Ran Womble's GOP fixer on .VOB in test mode (its "scan GOP time codes, video
>   and audio PTS, and GOP size errors" function) -- no errors reported.
> Each new .MPG/.TS file generated by the tasks above, incidentally, also played
> without AV sync+skipping problems in VLC and MPC.
> Finally:
> I tried these three tests (playback tested only in MPlayer for Windows r31027
> from http://mulder.at.gg/ since MPC/VLC didn't like the AVI wrapper for MPEG):
> * Stream copy both:
>   mencoder.exe input.vob -oac copy -ovc copy -o output1.avi
>   Result: output1.avi A/V sync NOT broken+no audible skipping.
> * Encode video, stream copy audio:
>   mencoder.exe input.vob -ofps 29.97 -vf scale=640:480,denoise3d,softskip,harddup -oac copy -ovc x264 -x264encopts bitrate=1200:pass=1 -o nul
>   mencoder.exe input.vob -ofps 29.97 -vf scale=640:480,denoise3d,softskip,harddup -oac copy -ovc x264 -x264encopts bitrate=1200:pass=2 -o output2.avi
>   Result: output2.avi A/V sync NOT broken+no audible skipping.
> * Encode audio, stream copy video:
>   mencoder.exe input.vob -af volnorm=1 -oac mp3lame -lameopts abr:br=192 -srate 32000 -ovc copy -o output3.avi
>   Result: output3.avi A/V sync BROKEN + audible skipping.
> Aha, the AC3.  So I demuxed the VOB using Womble to get at the AC3.  Ran the
> demuxed AC3 through http://www.free-codecs.com/download/ac3fix.htm but "No bad
> frames encountered" was the result, and doing a binary compare (Windows'
> "fc.exe /b infile outfile") of the demuxed AC3 with the new AC3 spit out by
> ac3fix found no differences.
> The demuxed AC3 also plays fine in MPC, VLC, and MPlayer for Windows r31027
> (no audible skipping).
> So.  It would seem there is *something* about this video file, quite possibly
> its AC3 audio, that MEncoder just cannot handle ... yet which VLC, MPC, MPlayer,
> Womble, and AutoGK's backend software can transcode/play just fine.
> And that's where I fail to see what to do next.  Besides making a copy of the
> VOB available and asking if any uber experts reading this can determine why
> MEncoder refuses to generate a synced and non-audio-skipping .avi from it.  :-)
> Here:  http://www.megaupload.com/?d=DXFZ65LC
> Note that the .VOB is huge (600 MB), so to make this download as inoffensive
> as possible, I used Womble to stream-copy just its first 230 MB into a VOB-
> free .MPG file.  Don't worry, I checked, and MEncoder's AV desync+skipping
> problem isn't altered by doing this.  Whatever problem exists in the original
> VOB carries over to the shorter MPG.  So this is only to save downloading
> time and shouldn't taint "exhibit A".  Anyway: the "Dreyfus" TV commercial at
> the MPG file's end is where the desync problem reveals itself.  Up until then,
> the MPG file's video (Amiga computer graphics) has nothing to do with its
> audio (instrumental music -- so there, you can only listen for the skipping
> issue).  Hence the need to copy at least 230 MB.

I tried encoding your sample as such:

mencoder VTS_01_VOBID_001_1.MPG -oac mp3lame -ovc x264 \
  -vf scale=640:480,denoise3d,softskip,harddup \
  -x264encopts keyint=250:keyint_min=25:bframes=3:b-adapt=2:b-pyramid=normal:deblock=-1,-1:vbv_maxrate=40000:vbv_bufsize=30000:aq-mode=1:qcomp=0.7:trellis=2:partitions=i8x8,i4x4,p8x8,p4x4,b8x8:direct=auto:weight_b:weightp=2:me=umh:subme=7:mixed_refs:8x8dct:level_idc=41:nodct_decimate:force-cfr:psy_rd=1.0,0.2:ref=4:mbtree:threads=6:bitrate=1500:turbo=2:pass=1 \
  -o /dev/null

mencoder VTS_01_VOBID_001_1.MPG -oac mp3lame -ovc x264 \
  -vf scale=640:480,denoise3d,softskip,harddup \
  -x264encopts keyint=250:keyint_min=25:bframes=3:b-adapt=2:b-pyramid=normal:deblock=-1,-1:vbv_maxrate=40000:vbv_bufsize=30000:aq-mode=1:qcomp=0.7:trellis=2:partitions=i8x8,i4x4,p8x8,p4x4,b8x8:direct=auto:weight_b:weightp=2:me=umh:subme=7:mixed_refs:8x8dct:level_idc=41:nodct_decimate:force-cfr:psy_rd=1.0,0.2:ref=4:mbtree:threads=6:bitrate=1500:pass=2 \
   -o test.avi

And as far as I could tell, the sync was still good at the end where the
fellow appears and begins talking. Note that there isn't anything special
about the x264encopts, I just grabbed them out of an encoding script I
use. Are you running a version of mencoder from SVN?

More information about the MEncoder-users mailing list