[FFmpeg-devel] [PATCH 4/5] Prefer pts over dts in timestamp correction

Baptiste Coudurier baptiste.coudurier
Mon Sep 13 06:15:57 CEST 2010


Hi Alexander,

On 9/12/10 8:06 PM, Alexander Strange wrote:
> On Tue, Jul 27, 2010 at 9:10 AM, Michael Niedermayer<michaelni at gmx.at>  wrote:
>> On Mon, Jul 26, 2010 at 01:16:09PM -0700, Alexander Strange wrote:
>>> Fixes decoder delay incorrectly causing the output picture timestamps
>>> to change.
>>> ---
>>>   cmdutils.c |    2 +-
>>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/cmdutils.c b/cmdutils.c
>>> index cd0b194..f86a182 100644
>>> --- a/cmdutils.c
>>> +++ b/cmdutils.c
>>> @@ -682,7 +682,7 @@ int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int6
>>>           ctx->num_faulty_pts += reordered_pts<= ctx->last_pts;
>>>           ctx->last_pts = reordered_pts;
>>>       }
>>> -    if ((ctx->num_faulty_pts<ctx->num_faulty_dts || dts == AV_NOPTS_VALUE)
>>> +    if ((ctx->num_faulty_pts<=ctx->num_faulty_dts || dts == AV_NOPTS_VALUE)
>>>          &&  reordered_pts != AV_NOPTS_VALUE)
>>>           pts = reordered_pts;
>>>       else
>>
>> This looks like your code doesnt work with dts.
>> A file can require the use of dts by not having pts or having incorrect
>> pts, this code is there to select which of dts/pts is better.
>> Biasing slightly to pts isnt going to help if there are no pts or wrong
>> pts.
>>
>
> Here's the specific problem + some other related ones.
>
> dts can be in-order and valid when it was written but still wrong. The
> problem I found is that if the initial decoder delay is underspecified
> (like h264 without num_reorder_frames set), there can be some dts
> value in the file and it will use that, but all the times will be
> assigned to the wrong pictures.
>
> Using a logging patch (attached) + this file which doesn't have
> num_reorder_frames + ffplay -strict 1 with this file:
> http://astrange.ithinksw.net/ffmpeg/camp_mot_mbaff0_full.mp4
>
> Before:
> pts - 0, pkt dts - 0, chose - 0 (no picture)
> pts - 0, pkt dts - 3003, chose - 3003 (no picture)
> pts - 0, pkt dts - 6006, chose - 6006 (no picture)
> pts - 0, pkt dts - 9009, chose - 9009 (no picture)
> pts - 0, pkt dts - 12012, chose - 12012 (no picture)
> pts - 0, pkt dts - 15015, chose - 15015 (no picture)
> pts - 0, pkt dts - 18018, chose - 18018 (no picture)
> pts - 0, pkt dts - 21021, chose - 21021 (no picture)
> pts - 0, pkt dts - 24024, chose - 24024 (no picture)
> pts - 0, pkt dts - 27027, chose - 27027 (no picture)
> pts - 0, pkt dts - 30030, chose - 30030 (no picture)
> pts - 0, pkt dts - 33033, chose - 33033 (no picture)
> pts - 0, pkt dts - 36036, chose - 36036 (no picture)
> pts - 0, pkt dts - 39039, chose - 39039 (no picture)
> pts - 0, pkt dts - 42042, chose - 42042 (no picture)
> pts - 0, pkt dts - 45045, chose - 45045 (no picture)
> pts - 3003, pkt dts - 48048, chose - 48048
> pts - 6006, pkt dts - 51051, chose - 51051
> pts - 9009, pkt dts - 54054, chose - 54054
>

Hummm pts seems correctly set on this file. What's wrong with it ?

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list