[theora-dev] A/V sync in Theora

David Kuehling dvdkhlng at gmx.de
Thu Jun 12 10:49:02 PDT 2003

>>>>> "Ralph" == Ralph Giles <giles at xiph.org> writes:

> On Thursday, June 12, 2003, at 05:30 pm, David Kuehling wrote:
>> Is ist valid for Vorbis packets to drift the granulepos to compensate
>> for A/V sync?  That would mean that granulepos does not represent the
>> number of actually played samples any more.  Seems like an ugly hack.

> Yes it does. Counter to spec too, so I don't recommend it.

> I guess I'm perplexed from the other end. The vorbis granulepos is in
> number of samples, so multiply by the sample rate to get a timestamp.
> The theora granulepos can be converted to the frame index, which you
> multiply by the framerate to get a timestamp. Those timestamps should
> align at playback. It's up to the player to work out how to make that
> happen.

Now you really startled me.  What you write makes sense but I'm quite
sure that it will break in pratical use.  Take a 2hour MPEG2 movie.
Demux and decode it into a stream of temporal equidistant pictures and a
stream of equidistant audio samples.  You know the exact frame rate,
25FPS and the sample is 44100.0 .  Try to recombine this into a usuable
video.  It wont work.  

Audio and video were recorded with hardware which was not synchronized.
No soundcard will give you 44100 Hz sample rate.  There is considerable
inaccuracy in both sample and frame rate.  Without timestamps obtained
from one single time source, your result will have a A/V-delay/drift.

The utility `ogmmerge', which discards timestamps when muxing video and
audio sources, is a good example of how this strategy fails.  I usually
get audio delays from 200ms to some seconds when using it on longer

So how do I encode actual timestamps into Theora?


GnuPG public key: http://user.cs.tu-berlin.de/~dvdkhlng/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'theora-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.

More information about the Theora-dev mailing list