[MEncoder-users] x264 questions

Peter Cordes peter at cordes.ca
Sat Nov 24 21:19:23 CET 2007


On Wed, Nov 07, 2007 at 05:54:21PM -0700, Loren Merritt wrote:
> On Tue, 6 Nov 2007, Rich Felker wrote:
> > On Tue, Nov 06, 2007 at 11:01:40AM -0800, RC wrote:
> >> On Tue, 6 Nov 2007 13:50:25 -0500
> >> Rich Felker <dalias at aerifal.cx> wrote:
> >>
> >>> Nope, nothing was fixed. The files will still be horribly broken.
> >>> Someone just removed that option without asking me while I was away
> >>
> >> ------------------------------------------------------------------------
> >> r23976 | michael | 2007-07-31 10:28:47 -0700 (Tue, 31 Jul 2007) | 5
> >> lines
> >>
> >> get rid of this idiotic
> >> i_certify_that_my_video_stream_does_not_use_b_frames muxer_lavf can now
> >> generate correct files with b frames as long as the timestamps provided
> >> to it are correct (they should be with lavc encoding, expect trouble
> >> with stream copy though)
> >
> > Hmm, since when does mencoder use the timestamps at all??? AFAIK it
> > does not... Can anyone confirm that this works? If so then mencoder is
> > nowhere near as broken as we expect it to be, but I'm quite
> > doubtful...
> 
> ~> mencoder -ovc lavc -of lavf -lavfopts format=mp4 in.avi -o out.mp4
> Works.
> 
> ~> mencoder -ovc lavc -lavcopts vmax_b_frames=1 -of lavf -lavfopts format=mp4 in.avi -o out.mp4
> Horribly broken. mplayer -demuxer mp4 can't even decode it, let alone 
> check timestamps. -demuxer lavf and ffplay work. MP4Box can't parse it.
> 
> ~> mencoder -ovc lavc -lavcopts vmax_b_frames=1 -of lavf -lavfopts format=mkv in.avi -o out.mkv
> Works, including correct timestamps.
> 
> ~> mencoder -ovc x264 -x264encopts qp=20:bframes=1 -of lavf -lavfopts format=mp4 in.avi -o out.mp4
> Wrong timestamps. mplayer plays it anyway.
> 
> ~> mencoder -ovc x264 -x264encopts qp=20:bframes=1 -of lavf -lavfopts format=mkv in.avi -o out.mkv
> Wrong timestamps. mplayer plays it anyway.

 With mkv output, I found that the output of the first pass plays ok in vlc.
But now that I've tried it again, it doesn't seem to be working for me.

 Output of second (and later) passes play with the frames in the wrong
order, so everything jitters back and forth.  This is like what you get with
raw .264 output played back by mplayer.  The first pass plays smoothly, but
later passes play out of order.

 I'm going to try using mkvextract to get raw .264, then
MP4Box -new -flat ...
mkvmerge ...
 This might finally be a reliable way to keep A/V sync.  I've never been
happy with A/V sync from encoding separately, because with x264
bframes=16:b_pyramid the decoding delay is 2 frames.  Writing to a raw .264
file, mencoder seems to think it has to drop or add 2 framesat the beginning
(don't remember which) because it doesn't have anywhere to pass on the 2
frame time offset information.  If you iterate an encode, it gets more and
more out of sync, and loses a couple frames each time.

  I've tried messing around with -delay $((fps * 2)) or stuff like that on
the mencoder -of rawvideo, but I feel I have to check the A/V sync by eye to
make sure it worked right.  And that is very hard to do.  I usually try to
find a section of silence followed by a sharp sound, usually something
hitting something else in the video.  mplayer's a/v sync isn't designed for
repeatability, which is a big problem with this method.  Another thing I've
tried is playing back the source video and my encoded video at the same
time, and trying to sync their sounds, then comparing the video.  My eyes
just aren't fast enough to see if one is one frame ahead or not.  (And it
takes a long time to get two soundtracks synced by slowing one of them with
[ followed by backspace.)

-- 
#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter at cor , des.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC



More information about the MEncoder-users mailing list