diff options
author | llyyr <llyyr.public@gmail.com> | 2023-09-21 23:03:16 +0530 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-09-22 12:14:16 +0200 |
commit | 84d6044d2bd4b0a2b6bc8d6f3deaf37747619284 (patch) | |
tree | a3a93e6300359f398e7bff934af8340c21e5b165 /demux/demux_lavf.c | |
parent | f09ebc871c9278e1ff1f21058df1cd8d7de19f9e (diff) | |
download | mpv-84d6044d2bd4b0a2b6bc8d6f3deaf37747619284.tar.bz2 mpv-84d6044d2bd4b0a2b6bc8d6f3deaf37747619284.tar.xz |
demux_lavf: set duration to -1 if unknown
`demux->duration` is set to -1 on initialization, and some checks rely
on it being -1 when unknown. Before this commit, we set
`demux->duration` to 0 when unknown. This is incorrect and breaks rtsp
logic for disabling seeking outside of cached regions.
To fix these issues, initialize `total_duration` and `av_duration` at
-1. They're only changed if a real duration is detected, so in cases
where the duration is unknown, demux->duration is set to -1 correctly.
Fixes: e6afc53e7c ("demux_lavf: get total duration from track durations")
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r-- | demux/demux_lavf.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index ed4d1a21f5..81791915f2 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; |