[MEncoder-users] A/V sync problems

Grozdan Nikolov microchip at chello.be
Fri Aug 3 16:27:20 CEST 2007


On Friday 03 August 2007 06:32, Corey Hickey wrote:
> Grozdan Nikolov wrote:
> > On Friday 03 August 2007 05:59, Corey Hickey wrote:
> >> Grozdan Nikolov wrote:
> >>> Hi,
> >>>
> >>> I'm having a problem with a soft telecined NTSC DVD. During playback
> >>> time of this DVD, mplayer repeatedly reported frame rate switching
> >>> between 23.97 and 23.976 fps. After watching the movie, I decided to
> >>> encode it and I used the pullup filter to remove the telecine from
> >>> it...
> >>>
> >>> -vf pullup,softskip,scale=608:384 -ofps 24000/1001
> >>
> >> What was your full command line?
> >
> > Pass 1
> >
> > mencoder dvd://1 -dvd-device /home/microchip/DVD -ofps 24000/1001 -vf
> > pullup,softskip,crop=720:480:0:0,scale=608:384:0:0 -sws 10 -nosound -ovc
> > x264 -x264encopts
> > pass=1:crf=19:turbo=1:me=umh:me_range=19:nodct_decimate:nointerlaced:8x8d
> >ct:threads=auto:nofast_pskip:nobrdo:trellis=1:partitions=p8x8,b8x8,i8x8,i4
> >x4:mixed_refs:bime:frameref=3:bframes=4:b_adapt:b_pyramid:weight_b:direct_
> >pred=auto:subq=5:chroma_me:cabac:deblock -passlogfile
> > /home/microchip/.h264enc/h264.log -o /dev/null 2>/dev/null
> >
> > Pass 2
> >
> > mencoder dvd://1 -dvd-device /home/microchip/DVD -ofps 24000/1001 -vf
> > pullup,softskip,crop=720:480:0:0,scale=608:384:0:0 -sws 10 -aid 128
> > -channels 4 -oac faac -faacopts mpeg=4:br=170:object=2 -ovc x264
> > -x264encopts
> > pass=2:bitrate=1070:me=umh:me_range=19:nodct_decimate:nointerlaced:8x8dct
> >:threads=auto:nofast_pskip:nobrdo:trellis=1:partitions=p8x8,b8x8,i8x8,i4x4
> >:mixed_refs:bime:frameref=3:bframes=4:b_adapt:b_pyramid:weight_b:direct_pr
> >ed=auto:subq=5:chroma_me:ssim:cabac:deblock -passlogfile
> > /home/microchip/.h264enc/h264.log -o /home/microchip/H264.avi
> >
> > does it has something to do with me not adding -fps 30000/1001 in
> > addition to -ofps 24000/1001 ?
>
> No... I don't know what's wrong, but unless you get a better response,
> here's what I suggest:
>
> 1. Get rid of "-sws 10" and every x264 option that slows down the
> encoding. You want to be able to test quickly.
>
> 2. Use "-oac copy" for handling sound in _both_ passes. Having different
> sound options in each pass is a bad idea because mencoder will handle
> A-V sync slightly differently, and drop different frames; x264 (and
> lavc, etc.) base their 2nd-pass encoding decisions on the sequence of
> frames seen in the first pass, and that sequence is altered if different
> frames are dropped. Unless I'm mistaken, using different sound options
> shouldn't actually mess up the A-V sync, but I might be wrong.

OK, here's what I did so far. First I encoded the whole DVD in 1-pass
mode with the crf and -oac copy options. Encoding was really fast at ~90 FPS.
I used the fast bilinear scaler together with a very low resolution and
some of the x264 options disabled or lowered to speed up encoding.

mencoder dvd://1 -dvd-device /home/microchip/DVD -fps 30000/1001 -ofps 
24000/1001 -vf pullup,softskip,crop=720:480:0:0,scale=320:176:0:0 -sws 0 -oac 
copy -ovc x264 -x264encopts 
crf=19:me=dia:frameref=1:subq=1:nochroma_me:nocabac:nodeblock
-o crf-audiocopy.avi

There were no A/V sync issues at all. Then I did the same, only this time I 
used as audio codec AAC with 4 channels:

mencoder dvd://1 -dvd-device /home/microchip/DVD -fps 30000/1001 -ofps 
24000/1001 -vf pullup,softskip,crop=720:480:0:0,scale=320:176:0:0 -sws 0 -oac 
faac -faacopts mpeg=4:br=140:object=2 -channels 4 -ovc x264 -x264encopts
crf=19:me=dia:frameref=1:subq=1:nochroma_me:nocabac:nodeblock -o 
crf-aac4channels.avi

This time, encoding was at ~61 FPS because of the audio and video 
simultaneously encoding. Again, as was in the first run, there were no A/V 
sync issues.

The final test I did was a 2-pass encode with both first and second pass using 
the same audio settings instead of the -nosound option I previousely used for 
the first pass:

Pass 1

mencoder dvd://1 -dvd-device /home/microchip/DVD -fps 30000/1001 -ofps 
24000/1001 -vf pullup,softskip,crop=720:480:0:0,scale=320:176:0:0 -sws 0 -oac 
faac -faacopts mpeg=4:br=140:object=2 -channels 4 -ovc x264 -x264encopts
pass=1:crf=19:me=dia:frameref=1:direct_pred=auto:subq=1:nochroma_me:nocabac:nodeblock
-o /dev/null

Pass 2

mencoder dvd://1 -dvd-device /home/microchip/DVD -fps 30000/1001 -ofps 
24000/1001 -vf pullup,softskip,crop=720:480:0:0,scale=320:176:0:0 -sws 0 -oac 
faac -faacopts mpeg=4:br=140:object=2 -channels 4 -ovc x264
-x264encopts 
pass=2:bitrate=900:me=dia:frameref=1:direct_pred=auto:subq=1:nochroma_me:nocabac:nodeblock
-o 2pass-aac4channels.avi

Again, as was the case for the previous runs, there were no A/V sync issues at 
all.

Conclusion: it seems that when doing a inverse telecine process and when using 
the -nosound option for the first pass in 2-pass encoding, mencoder slightly 
breaks A/V sync. I guess this has to do with frame skipping/duplicate frames

>
> 3. Do a test encode and see what happens. If it encodes fine, try to
> work backwards from there. If you have the same problem, take a close
> look and see if there's a constant A-V drift or if there's a
> discontinuity (fine before, desync after). Report back here for more
> help if you need.
>
> -Corey
> _______________________________________________
> MEncoder-users mailing list
> MEncoder-users at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/mencoder-users



More information about the MEncoder-users mailing list