[theora-dev] Time in video file

Richard Watts rrw at kynesim.co.uk
Tue Mar 15 10:54:44 PDT 2011

On 15/03/11 17:41, Benjamin M. Schwartz wrote:
> On 03/15/2011 01:36 PM, Bjoern D. Rasmussen wrote:
>> Since Theora is fed with a
>> framerate which isn't precise the time of each frame when I play it in
>> VLC doesn't match the exact time of when the frame occurred. So
>> basically I wonder how can I sync a video frame to a clock using
>> Theora and Ogg?
> Ogg Theora operates at a strictly fixed framerate.  If you start the
> stream at 30 fps, then it is a 30 fps stream, and the time of each frame
> is exactly determined by its number.  If your webcam is dropping frames
> then you must fill in the gaps.  You can most easily do this by submitting
> frames multiple times to make up for any dropped frames.

  What generally happens in video codec land is that the codec headers contain a
nominal frame rate, but you will only use that in practice to set your expectations
of the approximate rate of arrival of frames.

  Pacing is generally done by a more accurate clock delivered around the side
(e.g. via Ogg's granulepos - which is a completely abstract value that can mean
anything you like, but in practice tends to be a timestamp in ms).

  This is how I've been doing things for VFR (and how Cortado does it) and it works.
It's possible that the Theora community is virulently against this, of course, but
I've seen nothing to suggest that.

  (and in fact submitting frames multiple times is a terrible way to generate
a stream of anything other than integer N x the frame rate you're getting
from your input - it works OK for occasional dropped frames, but you'll see
a jerk every time you do it; you could, of course, generate a 120fps 'base'
stream with 3x repetition of each frame and hope to get more accurate timing
like that, but that way lies 1000fps streams and consequent madness .. )


More information about the theora-dev mailing list