[Theora] concatenate ogg/theora files
giles at xiph.org
Fri Dec 16 13:32:52 PST 2005
On Fri, Dec 16, 2005 at 08:46:04PM +0100, David Kuehling wrote:
> BTW I just realize that you might get problems with A/V sync if you
> concatenate too many theora streams in that way, since there are no real
> audio nor video time stamps in Theora. With the video and audio packets
> differing in their playback length, which are not multiples of each
> other, you will introduce a slight A/V offset at every concatenation
> point. By dropping/stuffing audio packets, you might however be able to
> keep the desync below one half of the playback time of one vorbis
To clarify, vorbis audio uses some special case logic and the beginning
and end of an Ogg segment to achieve gapless, sample-accurate playback;
if you remove the Ogg chain boundaries there is no way to trigger this
prune logic, introducing not only a possible sync offset, but some gap
in the audio as well.
This can be smoothed over by re-encoding a few "bridge" packets. You
have to that do anyway to avoid getting noise at the stream join: vorbis
packets are lapped with the data from the previous packet and abutting
two unrelated streams won't always be clean. So while the theora joiner
is probably only 300 lines, the vorbis one is more complicated.
And as David says, you'll always have up to half a vorbis packet sync
error because you lose the ability to reset the audio clock at the ogg
chain boundary. You can fix this up by adding or dropping theora video
frames so it's no worse than on half a video frame sync error if video
frames are less frequent, of course.
To get back to Rakotomandimby's original question, probably what's
happening is that you're too close to the limit of your network
throughput and the bandwidth spike of sending the new headers causes
icecast to drop you. You can either reduce your stream bitrate,
increase icecast's buffer size or both to work around the problem.
More information about the Theora