diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index ed4d1a21f5a6f..ce9238d51f928 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -1153,8 +1153,8 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) // We initially prefer track durations over container durations because they // have a higher degree of precision over the container duration which are // only accurate to the 6th decimal place. This is probably a lavf bug. - double total_duration = 0; - double av_duration = 0; + double total_duration = -1; + double av_duration = -1; for (int n = 0; n < priv->avfc->nb_streams; n++) { AVStream *st = priv->avfc->streams[n]; if (st->duration <= 0) @@ -1166,7 +1166,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) av_duration = MPMAX(av_duration, f_duration); } double duration = av_duration > 0 ? av_duration : total_duration; - if (duration == 0 && priv->avfc->duration > 0) + if (duration < 0 && priv->avfc->duration > 0) duration = (double)priv->avfc->duration / AV_TIME_BASE; demuxer->duration = duration;