[vlc-devel] ffmpeg VP8 encoder & pts weirdness

Francois Cartegnie fcvlcdev at free.fr
Sun Jan 5 23:15:16 CET 2014


Hi,

When trying to ogg mux VP8 + Vorbis:
sout_MuxGetStream( p_mux, 1, &i_dts)
is returning some -random- (and sometimes negative) offset'ed dts.

After intensive search, it seems the culprit is avcodec encoder.
avcodec/encoder.c ~1033

In the #if (LIBAVCODEC_VERSION_MAJOR >= 54) part, VP8 returns some
invalid pts set to AV_NOPTS_VALUE, which is here unhandled and then
overflows the pts.

I've tried some kind of fix:
p_block->i_pts = ( av_pkt.pts != AV_NOPTS_VALUE ) ? av_pkt.pts :
( ( frame && frame->pts != AV_NOPTS_VALUE ) ?
frame->pts :  p_sys->i_last_pts );
p_block->i_dts = ( av_pkt.dts != AV_NOPTS_VALUE ) ? av_pkt.pts :
( ( frame && frame->pts != AV_NOPTS_VALUE ) ?
frame->pts :  p_sys->i_last_pts );
assert( p_block->i_dts > 0 );

But that last assert still -randomly- fails with the same input data,
negative values other than AV_NOPTS_VALUE. Likely a bug somewhere.

As for now, the only way to have correctly stamped blocks is to assume
encoded block is source pts.

if ( frame ) /* because decoder might be flushing */
	p_block->i_dts = p_block->i_pts = frame->pts;

Any clue ?


Francois



More information about the vlc-devel mailing list