diff mbox

[FFmpeg-devel] lavf/mov.c: Set duration to zero if the duration is UINT_MAX

Message ID 1477510813-17137-1-git-send-email-isasi@google.com
State New
Headers show

Commit Message

Sasi Inguva Oct. 26, 2016, 7:40 p.m. UTC
Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead of zero.

Signed-off-by: Sasi Inguva <isasi@google.com>
---
 libavformat/mov.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Sasi Inguva Oct. 26, 2016, 7:42 p.m. UTC | #1
Attaching the file that it fixes.


On Wed, Oct 26, 2016 at 12:40 PM, Sasi Inguva <isasi@google.com> wrote:

> Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead
> of zero.
>
> Signed-off-by: Sasi Inguva <isasi@google.com>
> ---
>  libavformat/mov.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 357d800..245e424 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1221,6 +1221,11 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext
> *pb, MOVAtom atom)
>      sc->time_scale = avio_rb32(pb);
>      st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /*
> duration */
>
> +    if ((version == 1 && st->duration == UINT64_MAX) ||
> +        (version != 1 && st->duration == UINT32_MAX)) {
> +        st->duration = 0;
> +    }
> +
>      lang = avio_rb16(pb); /* language */
>      if (ff_mov_lang_to_iso639(lang, language))
>          av_dict_set(&st->metadata, "language", language, 0);
> --
> 2.8.0.rc3.226.g39d4020
>
>
Sasi Inguva Oct. 31, 2016, 5:22 p.m. UTC | #2
ping.

Thanks!

On Wed, Oct 26, 2016 at 12:42 PM, Sasi Inguva <isasi@google.com> wrote:

> Attaching the file that it fixes.
>
>
> On Wed, Oct 26, 2016 at 12:40 PM, Sasi Inguva <isasi@google.com> wrote:
>
>> Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead
>> of zero.
>>
>> Signed-off-by: Sasi Inguva <isasi@google.com>
>> ---
>>  libavformat/mov.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 357d800..245e424 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -1221,6 +1221,11 @@ static int mov_read_mdhd(MOVContext *c,
>> AVIOContext *pb, MOVAtom atom)
>>      sc->time_scale = avio_rb32(pb);
>>      st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /*
>> duration */
>>
>> +    if ((version == 1 && st->duration == UINT64_MAX) ||
>> +        (version != 1 && st->duration == UINT32_MAX)) {
>> +        st->duration = 0;
>> +    }
>> +
>>      lang = avio_rb16(pb); /* language */
>>      if (ff_mov_lang_to_iso639(lang, language))
>>          av_dict_set(&st->metadata, "language", language, 0);
>> --
>> 2.8.0.rc3.226.g39d4020
>>
>>
>
Yusuke Nakamura Nov. 1, 2016, 12:16 a.m. UTC | #3
2016-10-27 4:40 GMT+09:00 Sasi Inguva <isasi-at-google.com@ffmpeg.org>:

> Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead
> of zero.
>

What does this patch fix?


>
> Signed-off-by: Sasi Inguva <isasi@google.com>
> ---
>  libavformat/mov.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 357d800..245e424 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1221,6 +1221,11 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext
> *pb, MOVAtom atom)
>      sc->time_scale = avio_rb32(pb);
>      st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /*
> duration */
>
> +    if ((version == 1 && st->duration == UINT64_MAX) ||
> +        (version != 1 && st->duration == UINT32_MAX)) {
> +        st->duration = 0;
> +    }
> +
>      lang = avio_rb16(pb); /* language */
>      if (ff_mov_lang_to_iso639(lang, language))
>          av_dict_set(&st->metadata, "language", language, 0);
> --
> 2.8.0.rc3.226.g39d4020
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Sasi Inguva Nov. 1, 2016, 5:25 a.m. UTC | #4
For MP4F files , stream duration is updated by the sum of duration of
moof's
http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/mov.c;h=414007e7aa128aa66e07395b42c0cd4b369b3146;hb=HEAD#l4193
 , only if the duration in the header is less than that. Normally duration
field in header is 0, so this is ok. But some MP4F files have it set to
UINT_MAX , like the example I have uploaded.

On Mon, Oct 31, 2016 at 5:16 PM, Yusuke Nakamura <
muken.the.vfrmaniac@gmail.com> wrote:

> 2016-10-27 4:40 GMT+09:00 Sasi Inguva <isasi-at-google.com@ffmpeg.org>:
>
> > Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead
> > of zero.
> >
>
> What does this patch fix?
>
>
> >
> > Signed-off-by: Sasi Inguva <isasi@google.com>
> > ---
> >  libavformat/mov.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index 357d800..245e424 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -1221,6 +1221,11 @@ static int mov_read_mdhd(MOVContext *c,
> AVIOContext
> > *pb, MOVAtom atom)
> >      sc->time_scale = avio_rb32(pb);
> >      st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /*
> > duration */
> >
> > +    if ((version == 1 && st->duration == UINT64_MAX) ||
> > +        (version != 1 && st->duration == UINT32_MAX)) {
> > +        st->duration = 0;
> > +    }
> > +
> >      lang = avio_rb16(pb); /* language */
> >      if (ff_mov_lang_to_iso639(lang, language))
> >          av_dict_set(&st->metadata, "language", language, 0);
> > --
> > 2.8.0.rc3.226.g39d4020
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Sasi Inguva Nov. 3, 2016, 6:06 p.m. UTC | #5
ping.

Thanks!

On Mon, Oct 31, 2016 at 10:25 PM, Sasi Inguva <isasi@google.com> wrote:

> For MP4F files , stream duration is updated by the sum of duration of
> moof's http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/mov.c;h=
> 414007e7aa128aa66e07395b42c0cd4b369b3146;hb=HEAD#l4193  , only if the
> duration in the header is less than that. Normally duration field in header
> is 0, so this is ok. But some MP4F files have it set to UINT_MAX , like the
> example I have uploaded.
>
> On Mon, Oct 31, 2016 at 5:16 PM, Yusuke Nakamura <
> muken.the.vfrmaniac@gmail.com> wrote:
>
>> 2016-10-27 4:40 GMT+09:00 Sasi Inguva <isasi-at-google.com@ffmpeg.org>:
>>
>> > Fixes some MP4F files which have duration in mdhd set to UINT_MAX
>> instead
>> > of zero.
>> >
>>
>> What does this patch fix?
>>
>>
>> >
>> > Signed-off-by: Sasi Inguva <isasi@google.com>
>> > ---
>> >  libavformat/mov.c | 5 +++++
>> >  1 file changed, 5 insertions(+)
>> >
>> > diff --git a/libavformat/mov.c b/libavformat/mov.c
>> > index 357d800..245e424 100644
>> > --- a/libavformat/mov.c
>> > +++ b/libavformat/mov.c
>> > @@ -1221,6 +1221,11 @@ static int mov_read_mdhd(MOVContext *c,
>> AVIOContext
>> > *pb, MOVAtom atom)
>> >      sc->time_scale = avio_rb32(pb);
>> >      st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /*
>> > duration */
>> >
>> > +    if ((version == 1 && st->duration == UINT64_MAX) ||
>> > +        (version != 1 && st->duration == UINT32_MAX)) {
>> > +        st->duration = 0;
>> > +    }
>> > +
>> >      lang = avio_rb16(pb); /* language */
>> >      if (ff_mov_lang_to_iso639(lang, language))
>> >          av_dict_set(&st->metadata, "language", language, 0);
>> > --
>> > 2.8.0.rc3.226.g39d4020
>> >
>> > _______________________________________________
>> > ffmpeg-devel mailing list
>> > ffmpeg-devel@ffmpeg.org
>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> >
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
>
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 357d800..245e424 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1221,6 +1221,11 @@  static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     sc->time_scale = avio_rb32(pb);
     st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
 
+    if ((version == 1 && st->duration == UINT64_MAX) ||
+        (version != 1 && st->duration == UINT32_MAX)) {
+        st->duration = 0;
+    }
+
     lang = avio_rb16(pb); /* language */
     if (ff_mov_lang_to_iso639(lang, language))
         av_dict_set(&st->metadata, "language", language, 0);