[FFmpeg-devel] [PATCH] avformat/mov: read stream bitrates from isml manifest

Michael Niedermayer michaelni at gmx.at
Fri Jul 5 21:37:24 CEST 2013


On Fri, Jul 05, 2013 at 04:07:16PM +0200, Alexandre Sicard wrote:
> This allows to read a live isml movie and segment it using the
> smoothstreaming muxer, which requires the bitrates to be known for each stream.
> 
> Signed-off-by: Alexandre Sicard <alexandre.sicard at smartjog.com>
> ---
>  libavformat/isom.h |  2 ++
>  libavformat/mov.c  | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 76 insertions(+)
> 
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 220b2df..b0fa453 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -162,6 +162,8 @@ typedef struct MOVContext {
>      int use_absolute_path;
>      int ignore_editlist;
>      int64_t next_root_atom; ///< offset of the next root atom
> +    int *bitrates;          ///< bitrates read before streams creation
> +    int bitrates_count;
>  } MOVContext;
>  
>  int ff_mp4_read_descr_len(AVIOContext *pb);
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 37030a5..2f2a6a7 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -2731,6 +2731,72 @@ static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>      return 0;
>  }
>  
> +static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +    int ret;
> +    uint8_t uuid[16];
> +    static const uint8_t uuid_isml_manifest[] = {
> +        0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
> +        0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
> +    };
> +
> +    if (atom.size < sizeof(uuid) || atom.size == INT64_MAX)
> +        return AVERROR_INVALIDDATA;
> +
> +    ret = avio_read(pb, uuid, sizeof(uuid));
> +    if (ret < 0) {
> +        return ret;
> +    } else if (ret != sizeof(uuid)) {
> +        return AVERROR_INVALIDDATA;
> +    }
> +    if (!memcmp(uuid, uuid_isml_manifest, sizeof(uuid))) {
> +        uint8_t *buffer, *ptr;
> +        char *endptr;
> +        size_t len = atom.size - sizeof(uuid);
> +
> +        if (len < 4) {
> +            return AVERROR_INVALIDDATA;
> +        }
> +        ret = avio_skip(pb, 4); // zeroes
> +        len -= 4;
> +
> +        buffer = av_mallocz(len + 1);
> +        if (!buffer) {
> +            return AVERROR(ENOMEM);
> +        }
> +        ret = avio_read(pb, buffer, len);
> +        if (ret < 0) {
> +            av_free(buffer);
> +            return ret;
> +        } else if (ret != len) {
> +            av_free(buffer);
> +            return AVERROR_INVALIDDATA;
> +        }
> +
> +        ptr = buffer;

> +        while ((ptr = strcasestr(ptr, "systemBitrate=\"")) != NULL) {

strcasestr() is not portable, please use something else

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130705/60e1e1c4/attachment.asc>


More information about the ffmpeg-devel mailing list