summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-08-23 12:23:22 +0200
committerwm4 <wm4@nowhere>2020-08-23 12:44:54 +0200
commit74e62ed2d1e2058f6dbc9e8b9f759c20493e25bf (patch)
tree80bb8f2b1e33d381b8272ed7924d0805e9771747
parentc9c01a07f8e5846379b0fe01eb9320f4e8519bb5 (diff)
downloadmpv-74e62ed2d1e2058f6dbc9e8b9f759c20493e25bf.tar.bz2
mpv-74e62ed2d1e2058f6dbc9e8b9f759c20493e25bf.tar.xz
Revert "demux_lavf: always give libavformat the filename when probing"
This reverts commit 41243e7c4f98b410195397b6758f9796acd9de57. This fixes image format detection. FFmpeg has an utter called "image2", which is designed to read patterns in filenames (so you can play something like "%*.jpg" for all jpg files in the current directory). "image2" is not what we want; it's just broken with custom I/O like mpv uses it, and we don't want to "accidentally" interpret filenames as pattern. That's why mpv blacklists it. Unfortunately, "image2" is sometimes the format that FFmpeg's probe API returns as best match. Thus demux_lavf fails to detect the file type, and after some more futile attempts, we end up at demux_mf, which uses detection by file extension. (Not sure why. I guess MPlayer did that, and foudn that sufficient.) If the file extension is wrong (which happens a lot because apparently the world is full of idiots who don't manage to get the most simple things right), the image "loads", but decoding obviously fails. There's no easy way around this. The FFmpeg API has no mechanism to exclude a specific format from probing (like image2, which breaks stuff for us). Out of the 5 probe functions the API provides, none can probe a specific format or include or exclude specific formats. The main problem is that AVInputFormat.read_probe is a private symbol. FFmpeg itself has no problem opening such files. It turns out that it works, because even though image2 by itself uses detection by file extension, it uses private API to further probe the exact format. It explicitly excludes itself to prevent recursion. But fortunately, that also means that it's impossible to get the image2 format if no filename is passed to the prober. (No filename, no file extension.) Apparently we pass it in because it helps in corner cases. Until almost 3 years ago, we passed the filename only when normal probing already failed. Restore this by this revert. It makes incorrectly named files work. The revert also makes the (apparently forgotten) comment above the touched line of code true again. Yes, quite possible that this breaks some mp3s again. You can't win with FFmpeg. Thanks FFmpeg for making us fail at opening simple image files and/or the most widely used file format for audio.
-rw-r--r--demux/demux_lavf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index e3ebcbfdc6..6aaf279c4b 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -463,7 +463,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
AVProbeData avpd = {
// Disable file-extension matching with normal checks
- .filename = priv->filename,
+ .filename = check <= DEMUX_CHECK_REQUEST ? priv->filename : "",
.buf_size = 0,
.buf = av_mallocz(PROBE_BUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE),
};