[FFmpeg-devel] [PATCH] Ogg/Speex muxer

Baptiste Coudurier baptiste.coudurier
Fri Feb 6 21:03:41 CET 2009


Hi Peter,

On 2/6/2009 8:00 AM, Peter Ross wrote:
> $subject.
> 
> [...]
>
> + */
> +static uint8_t* build_vorbis_comment_packet(AVFormatContext *s, int *size)
> +{
> +    int count,i;
> +    uint8_t *buf, *p;
> +
> +    /* calculate size of packet */
> +    count = 0;
> +    *size = 8 + strlen(LIBAVCODEC_IDENT);
> +    for(i=0; ogg_keys[i]; i++) {
> +        const char *key = ogg_keys[i];
> +        AVMetadataTag *tag = av_metadata_get(s->metadata, key, NULL, 0);
> +        if (tag) {
> +            count++;
> +            *size += 4 + strlen(key) + 1 + strlen(tag->value);
> +        }
> +    }
> +    *size += 1;
> +
> +    buf = av_malloc(*size);
> +    if (!buf)
> +        return NULL;
> +    p = buf;
> +
> +    bytestream_put_le32(&p, strlen(LIBAVCODEC_IDENT));
> +    bytestream_put_buffer(&p, LIBAVCODEC_IDENT, strlen(LIBAVCODEC_IDENT));
> +    bytestream_put_le32(&p, count);
> +    for(i=0; ogg_keys[i]; i++) {
> +        const char *key = ogg_keys[i];
> +        AVMetadataTag *tag = av_metadata_get(s->metadata, key, NULL, 0);
> +        if (tag) {
> +            bytestream_put_le32(&p, strlen(key)+1+strlen(tag->value));
> +            bytestream_put_buffer(&p, key, strlen(key));
> +            bytestream_put_byte(&p, '=');
> +            bytestream_put_buffer(&p, tag->value, strlen(tag->value));
> +        }
> +    }
> +    bytestream_put_byte(&p, 1); // framing bit
> +    return buf;
> +}
> +

Can the vorbis/speex comment code be applied separately and used with
vorbis ? If so please do that so vorbis can benefit of metadata too.

>  static int ogg_write_header(AVFormatContext *s)
>  {
>      OGGStreamContext *oggstream;
> @@ -123,7 +194,8 @@
>              av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
>          if (st->codec->codec_id != CODEC_ID_VORBIS &&
>              st->codec->codec_id != CODEC_ID_THEORA &&
> -            st->codec->codec_id != CODEC_ID_FLAC) {
> +            st->codec->codec_id != CODEC_ID_FLAC &&
> +            st->codec->codec_id != CODEC_ID_SPEEX) {
>              av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
>              return -1;

You can add SPEEX before FLAC and save one diff line :>

> @@ -140,6 +212,20 @@
>                  av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
>                  av_freep(&st->priv_data);
>              }
> +        } else if (st->codec->codec_id == CODEC_ID_SPEEX) {
> +            if (st->codec->extradata_size < 80) {
> +                av_log(s, AV_LOG_ERROR, "Extradata underflow\n");
> +                av_freep(&st->priv_data);
> +                return -1;
> +            }
> +            oggstream->header_len[0] = st->codec->extradata_size;
> +            oggstream->header[0] = st->codec->extradata;

Should we rebuild extradata when speex is in flv and therefore contains
none ?

[...]

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no
FFmpeg maintainer                                  http://www.ffmpeg.org




More information about the ffmpeg-devel mailing list