diff mbox

[FFmpeg-devel] lavf/mov: make invalid mdhd time_scale default to 1 instead of erroring out

Message ID 20170511143350.2782-1-matthieu.bouron@gmail.com
State Superseded
Headers show

Commit Message

Matthieu Bouron May 11, 2017, 2:33 p.m. UTC
Some samples have their metadata track time_scale incorrectly set to 0
and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71
prevents playback of those samples. Setting the time_scale to 1 fixes
playback.
---
 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer May 12, 2017, 9:12 p.m. UTC | #1
On Thu, May 11, 2017 at 04:33:50PM +0200, Matthieu Bouron wrote:
> Some samples have their metadata track time_scale incorrectly set to 0
> and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71
> prevents playback of those samples. Setting the time_scale to 1 fixes
> playback.
> ---
>  libavformat/mov.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

should be ok
please add a fate test

thx

[...]
Matthieu Bouron May 17, 2017, 11:56 a.m. UTC | #2
On Fri, May 12, 2017 at 11:12:12PM +0200, Michael Niedermayer wrote:
> On Thu, May 11, 2017 at 04:33:50PM +0200, Matthieu Bouron wrote:
> > Some samples have their metadata track time_scale incorrectly set to 0
> > and the check introduced by a398f054fdb9b0f0b5a91c231fba6ce014143f71
> > prevents playback of those samples. Setting the time_scale to 1 fixes
> > playback.
> > ---
> >  libavformat/mov.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> should be ok

Do you agree if I extend the patch to apply this behaviour to the mvhd
atoms (like a398f054fdb9b0f0b5a91c231fba6ce014143f71 originally did) ?

> please add a fate test

I will. Is it mandatory in order to get this patch applied (as I would
like to apply this patch as soon as possible) ?

[...]
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index afef53b79a..3c8b75ddb3 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1236,8 +1236,8 @@  static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     sc->time_scale = avio_rb32(pb);
     if (sc->time_scale <= 0) {
-        av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d\n", sc->time_scale);
-        return AVERROR_INVALIDDATA;
+        av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d, defaulting to 1\n", sc->time_scale);
+        sc->time_scale = 1;
     }
     st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */