[theora-dev] Video encoded using libtheora-1.1.1 and libogg-1.1.4 plays too fast...

Timothy B. Terriberry tterribe at email.unc.edu
Thu Feb 11 07:54:01 PST 2010

Id Kong wrote:
> Incidentally, encoder_example.c does not do this.  If I'm reading the
> code right, there is only one call to ogg_stream_pageout() for every
> loop of th_encode_packetout() and ogg_stream_packetin() calls.

No, encoder_example is not structured like this at all. It writes pages
one at a time, because it must mux audio and video, and the pages have
to be ordered according to the times associated with their granule
positions. It loops writing one page at a time so long as there is a
page available for both streams, and only if there are no pages
available for one of the streams does it submit more data for
compression (producing more packets).

> This resulted in a slight larger file but no discernible difference in
> the movie play length.  It's certainly not playing the expected duration.
> What do you think?

Since you're just compressing the same frame over and over again, what
you're likely getting is a keyframe followed by a bunch of zero-byte
packets, which is Theora's cheap way of saying "keep showing the last
frame". Some (broken) players treat these as semantically different,
however, and will end playback early when they appear at the end of a
stream. I suggest running ogginfo or oggzinfo on the file and see what
it says the real length is. You may also be interested in oggz-validate,
which can confirm that you are writing out all of the pages in the
proper order.

By the way, please do not use a constant for the stream serial number.
Multiple streams in the same file must have unique serial numbers, and
if someone later wants to concatenate multiple streams you produce, they
will have to rewrite the stream with a new serial number or (more
likely) will generate an invalid file.

More information about the theora-dev mailing list