diff options
author | Guido Cella <guido@guidocella.xyz> | 2024-04-18 16:41:17 +0200 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2024-04-18 16:48:25 +0200 |
commit | d0aeca59189c44b3999cc7add9d23642a73fe188 (patch) | |
tree | 59c5742df6b3b09c6e5dd2f2b5b0280b86fd822a /demux | |
parent | 750dec880c6294fba8457ea7f4b36a3dfcd1ebb5 (diff) | |
download | mpv-d0aeca59189c44b3999cc7add9d23642a73fe188.tar.bz2 mpv-d0aeca59189c44b3999cc7add9d23642a73fe188.tar.xz |
demux_lavf: pass jpg filenames to ffmpeg for probing
Fixes #13192, fixes #13431. See the comment for details.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_lavf.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index fa9fd5cee8..75a47ed3ad 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -464,12 +464,18 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check) } } - // HLS streams seems to be not well tagged, so matching mime type is not - // enough. Strip URL parameters and match extension. - bstr ext = bstr_get_ext(bstr_split(bstr0(priv->filename), "?#", NULL)); + // HLS streams do not seem to be well tagged, so matching by MIME type is + // not enough - we need to strip the query string and match by their + // extensions. We also pass jpg filenames to fix issues like #13192 (jpgs + // being treated as videos due to a bogus second frame) and #13431 (jpgs + // misdetected as mpegts). We don't pass filenames otherwise to not + // misdetect files with a wrong extension, as described in 74e62ed2d1. + bstr ext = bstr_get_ext(mp_is_url(bstr0(priv->filename)) + ? bstr_split(bstr0(priv->filename), "?#", NULL) + : bstr0(priv->filename)); AVProbeData avpd = { - // Disable file-extension matching with normal checks, except for HLS .filename = !bstrcasecmp0(ext, "m3u8") || !bstrcasecmp0(ext, "m3u") || + !bstrcasecmp0(ext, "jpg") || !bstrcasecmp0(ext, "jpeg") || check <= DEMUX_CHECK_REQUEST ? priv->filename : "", .buf_size = 0, .buf = av_mallocz(PROBE_BUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE), |