[FFmpeg-devel] Patch for chained OGG files

David Conrad lessen42
Tue Apr 13 00:45:42 CEST 2010

On Mar 31, 2010, at 1:48 PM, Cyril Zorin wrote:

> Hi!
> Attached is a patch that lets ffmpeg handle chained OGG files, often used in
> internet radio streams. Let me know if there's anything to change.

> +static int
> +ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
> +{
> +  const int result = ogg_read_packet_internal(s, pkt);
> +  if (result >= 0)
> +    return result;
> +
> +  ogg_read_close(s);
> +  memset(s->priv_data, 0, sizeof(struct ogg));
> +  if (ogg_read_header(s, 0) < 0)
> +    return AVERROR(EIO);
> +
> +  return ogg_read_packet_internal(s, pkt);
> +}

I don't like this approach of nuking the ogg struct.

The general approach I see for this is: when a new set of streams is found, create them and don't return from read_packet until all the parameters are set. I think we already almost do this except for ensuring that the needed parameters are set. This of course won't work with most things using lavf as they don't expect new streams mid-decode.

Thus the special case of the new set of streams exactly matching the old: don't create additional streams in that case and just remap the new serials to the existing streams after updating metadata. Only doing this when the first and third packets of the theora/vorbis streams match and there are no other non-skeleton streams we recognize should be good enough for basically all actual uses of chained ogg.

More information about the ffmpeg-devel mailing list