[Theora-dev] ogg and keyframes

Ralph Giles giles at xiph.org
Mon Sep 27 10:39:36 PDT 2004

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? 

> 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().

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

> 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.


More information about the Theora-dev mailing list