[FFmpeg-devel] Problem with initial dts in h264

John Stebbins jstebbins
Mon Dec 7 07:30:29 CET 2009

On 12/06/2009 07:15 PM, Michael Niedermayer wrote:
> On Sun, Dec 06, 2009 at 03:26:30PM -0800, John Stebbins wrote:
>> A recent change has caused the initial dts in h264 streams returned by
>> av_read_frame to be incorrect.  The commit was r20599.
>> This is especially obnoxious when the reader does a seek before
>> av_read_frame.
> send a patch that resets pts_buffer in av_read_frame_flush()
> (assuming its tested&  works of course)
> There may be further bugfixes needed but this one seems obviously missing

I thought that something should be resetting pts_buffers, but didn't 
know where that should be done.  So thanks for the pointer.  I think 
that av_read_frame_flush should also be called from av_find_stream_info 
since pts_buffer is modified during this function.  My patch does this.

I did some testing, and this patch fixes the problem I saw.  But as you 
noted, there seems to be more bugs.  I'm now seeing the dts start out 
ok. But it looks like st->codec->has_b_frames starts out at 2, changes 
to 0 on the second packet, then changes to 2 again a bit later.  When it 
changes back to 2, dts once again gets the wrong value for a sequence of 
several packets.  It appears that the change in delay screws up the 
ordering in pts_buffers.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: initial_dts.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091206/f8f5ce9a/attachment.txt>

More information about the ffmpeg-devel mailing list