[MPlayer-dev-eng] [PATCH] mencoder, B-frames, and video/audio delay

Rich Felker dalias at aerifal.cx
Fri Jan 27 06:52:31 CET 2006


On Thu, Jan 26, 2006 at 06:26:43PM -0800, Corey Hickey wrote:
> All right, here's patch #5. Changes from the previous:
> 
> 1. The encoder config() functions each initialize the delay variable:
> 0 if no B-frames
> 1 if any B-frames
> 2 if b_pyramid (which requires >1 B-frames, as well)
> This takes care of the decoding delay, and, since it's set right at the
> beginning, mencoder will start compensating immediately and skip 1 or 2
> frames as soon as it can.
> The encode_frame() functions still increment the delay variable each
> time the encoder doesn't output a frame, so that takes care of encoding
> delay nice and smoothly.
> 
> 2. I changed "encoder_delay" to "codec_delay" to represent that it's
> compensating for delays in both encoding and decoding.

IMO it's incorrect to compensate for it at this level. It's definitely
incorrect for muxers that can handle dts correctly. Like Michael has
said I'm not sure how dts is handled for avi by other player
implementations but it would be worth experimenting to see before we
make significant changes like this..

Anyway since having mencoder process the decode-delay like this is a
BUG WORKAROUND for avi's limitations (actually for the stupid idea of
storing B frames in avi files) and only applies to avi container, I
don't think it should be enabled all the time. Either just for avi, or
not at all. It's certainly incorrect to skip the first 1-2 frames when
muxing proper containers.

Rich




More information about the MPlayer-dev-eng mailing list