[FFmpeg-devel] [PATCH] ogg: Fix seek to zero and packet pts after read through.

Don Moir donmoir at comcast.net
Fri May 4 22:13:20 CEST 2012


----- Original Message ----- 
From: "Dale Curtis" <dalecurtis at chromium.org>
To: "FFmpeg development discussions and patches" <ffmpeg-devel at ffmpeg.org>
Sent: Friday, May 04, 2012 1:58 PM
Subject: Re: [FFmpeg-devel] [PATCH] ogg: Fix seek to zero and packet pts 
after read through.


> On Fri, May 4, 2012 at 5:52 AM, Michael Niedermayer 
> <michaelni at gmx.at>wrote:
>
>> On Thu, May 03, 2012 at 08:09:21PM -0700, Dale Curtis wrote:
>> > Sorry for the delay, I've been out on vacation the past week. The 
>> > pts/dts
>> > for the first frame on the first pass are 0,0. Why is it incorrect to
>> have
>> > a pts/dts of 0,0 on the second pass as well? Thanks in advance for your
>> > patience.
>>
>> 0,0 is incorrect, its wrong on the first AND second pass.
>>
>> Ive fixed it now.
>>
>
> Thanks Michael. I'm unable to reproduce the issues you're seeing though.
> Can you send me the test program and video you're using? I just reran my
> test case with our patch applied to ffmpeg HEAD and the timestamps are
> coming out correct:
>
> libre.ogg w/ patch and w/ video stream index seek:
> pts: 79211520 -- dts: 79211520
> pts: 79211520 -- dts: 79211520
> pts: 79212544 -- dts: 79212544
> pts: 79213568 -- dts: 79213568
> pts: 79214592 -- dts: 79214592
>
> seek to zero:
> pts: 79211520 -- dts: 79211520
> pts: 79211520 -- dts: 79211520
> pts: 79212544 -- dts: 79212544
> pts: 79213568 -- dts: 79213568
> pts: 79214592 -- dts: 79214592
>
> Time stamps on the video stream are also correct w/ the patch:
> pts: 44903 -- dts: 44903
> pts: 44904 -- dts: 44904
> pts: 44905 -- dts: 44905
> pts: 44906 -- dts: 44906
> pts: 44907 -- dts: 44907
>
> seek to zero:
> pts: 44903 -- dts: 44903
> pts: 44904 -- dts: 44904
> pts: 44905 -- dts: 44905
> pts: 44906 -- dts: 44906
> pts: 44907 -- dts: 44907
>
> Curiously using libre.ogg and seeking on the audio index w/o the patch
> yields the correct results too. Unfortunately this doesn't seem to work
> with sync1.ogg.
>
> I've repackaged the patch, test case, and stream snippet I'm using here, 
> so
> we can make sure we're on the same page:
>
> http://commondatastorage.googleapis.com/dalecurtis-shared/ogg-seek-test-2.tar.bz2
>
> - dale

With sync1.ogg the first packet dts and pts are -128. The first_dts is -128.

My seek function takes values from 0 to the duration. After rescaling this 
value, I add the first_dts to it. This gets it ready so that 
avformat_seek_file gets it right.

Doing this will always produce the correct dts and pts of -128 for sync1.ogg 
and other files.

Addtionally you might want to value check your requested timestamp before 
you seek.

if (pAudioStream->nb_index_entries)
{
    AVIndexEntry* pIndexEntry = (AVIndexEntry*)pAudioStream->index_entries;
    if (timestamp < pIndexEntry->timestamp)
        timestamp  = pIndexEntry->timestamp;
    else
    {
        int timeIndex = av_index_search_timestamp 
(pAudioStream,timestamp,AVSEEK_FLAG_BACKWARD);
        if (timeIndex >= 0)
            timestamp = 
((AVIndexEntry*)(pAudioStream->index_entries))[timeIndex].timestamp;
    }
}

libre.ogg seems all screwed up. Still looking at it. 



More information about the ffmpeg-devel mailing list