[Theora-dev] ogg and keyframes

Wim Taymans wim at fluendo.com
Tue Sep 28 01:12:27 PDT 2004

On Mon, 2004-09-27 at 19:39, Ralph Giles wrote:
> On Mon, Sep 27, 2004 at 04:13:05PM +0200, Wim Taymans wrote:
> > When doing a live ogg+theora stream on our server we ran into the
> > following problem: When a client connects we send out the theora header
> > pages followed by the actual live stream pages. The problem is that the
> > first ogg data page does not have the right page number (2), which
> > causes libogg to not want to decode the first _packet_ of that page.
> > Since that first packet happens to contain the keyframe of the theora
> > stream, most players (Mplayer) don't properly show the first frames
> > until a new keyframe is received. This is not nice.
> That would be a serious bug in libogg. 
> > 1) libogg does not refuse to decode the first packet, just warn. This
> > requires changing libogg behaviour.
> This is what it's supposed to do. It should return OV_HOLE to let the 
> caller know there's a gap in the data, but return the first decodable 
> packet anyway. This happens not only with streaming, but whenever you 
> seek. You're sure the packet begins on that page? 

I verified and it was my own fault. libogg is doing the right thing, I
wasn't. Well, it's fixed now, thanks.

> > 2) players don't show frames before they receive a keyframe.
> This has been suggested as a fix for dealing with lazy net streams that 
> don't start by sending a keyframe, and of course lazy seek, but I'd 
> rather it be handled by the player than libtheora. I added 
> theora_packet_iskeyframe() to the api for facilitate this.
> I suppose it could be an option set through theora_decode_ctl().

Ah, fine. Better than checking 'the second most significant bit of the
first data byte'. Can you also add some method to check if it's a header
packet or a data packet?

> Does this mean your server is starting connections by sending keyframes 
> now? :-)

When we find a new camera (donations welcome :)) it will be back up with
that bug finally fixed. 

> > 3) The server (or theora encoder) inserts an empty packet in the page
> > with the keyframe.
> This isn't necessary. If there's a libogg bug we're very interested in 
> fixing it.


> Cheers,
>  -r

More information about the Theora-dev mailing list