1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-31 19:52:16 +00:00

Revert "demux_lavf: pass jpg filenames to ffmpeg for probing"

Passing jpg filenames to ffmpeg is actually quite bad. This causes all
jpg images (at least in my testing) to be probed as image2 which is
blacklisted in demux_lavf since it's completely broken (see commit
74e62ed2d1 for some details). What happens
in practice is that the lavf demxuer fails and the it opens in the mf
demuxer instead. This is OK for simple viewing, but because that demuxer
is limited, many specific file properities and other things are
completely unavailable which breaks any script that may depend on them
(e.g. width, height, etc.) For the small subset of files that this
commit appeared to "fix" (in reality, it just fell back to the mf
demuxer) is not worth breaking property usage in the vast majority of
normal proper files. Ideally ffmpeg should fix this but some other
workaround on our end can be used instead.

This reverts commit d0aeca5918.
This commit is contained in:
Dudemanguy 2024-06-11 14:51:29 -05:00
parent b4bbc27d9c
commit a900d41b1e

View File

@ -465,18 +465,12 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
}
}
// 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));
// 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));
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),