[FFmpeg-devel] [PATCH] Fix for ogg timestamps when packets span multiple ogg pages

Måns Rullgård mans
Fri Dec 26 11:03:15 CET 2008

David Conrad <lessen42 at gmail.com> writes:

> On Dec 1, 2008, at 1:21 PM, Michael Niedermayer wrote:
>> On Sun, Nov 09, 2008 at 02:48:01AM -0500, David Conrad wrote:
>>> On Nov 6, 2008, at 5:51 PM, David Conrad wrote:
>>>> Hi,
>>>> The problem with the current code comes from how an ogg page with
>>>> only a partial packet uses the special granulepos of -1. The
>>>> granulepos needs to be saved from the last page that completed a
>>>> packet until the next page that completes a packet, where it is
>>>> the timestamp of the first complete packet.
>>> After looking at ogg granule_position some more, there's another
>>> problem in that Dirac and ogm both assume that the timestamp is
>>> the beginning of the associated packet, wheras Xiph codecs define
>>> the granule as the time after the associated packet is fully
>>> decoded (I'm assuming, I've only found Vorbis and Theora to do so
>>> explicitly.)
>>> Currently the ogg demuxer simply assumes that all codecs use the
>>> latter definition and does codec-specific interpretation of the
>>> granule on the next packet. This causes problems with determining
>>> Theora keyframes, as the frame after the actual keyframe gets the
>>> flag.
>>> Here's a general fix to always associate the granule and derived
>>> flags with the correct packet, and then delay the interpreted
>>> timestamp to the next packet for Xiph codecs. This fixes ogm
>>> timestamps, Theora keyframes, and allows for correct Dirac
>>> timestamps.
>> ping, i think the patch is still missing a review from our ogg
>> demuxer maintainer
> ping x2
> (I know M?ns said on irc he'd fix this possibly in a different way,  
> but it has been a while)

The Dirac people promised to fix/clarify their spec a bit.  I haven't
had time to check this yet, and right now I'm away for the holidays.
I haven't forgotten about this.

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list