From f385a6b25313c1d018f58523654c6b2313a72911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 9 Feb 2025 21:03:48 +0100 Subject: [PATCH] demux_lavf: fix demuxer-lavf-format usage mpv internally treats all string options/properties with NULL or an empty string the same way. client.h explicitly forbids MPV_FORMAT_STRING from being NULL, but in the C API, it has been working accidentally due to how strings are copied. Nevertheless, none of the APIs allow this; JavaScript, Lua, IPC, and CLI all require strings to be at least empty. We cannot pass NULL. Furthermore, currently passing NULL causes an assertion failure in the JSON formatter, so it is clearly not intended to be used that way. Internally, all string options default to NULL, but in this case, they should behave exactly the same as an empty string. Hence, this change is applied to the `demuxer-lavf-format` option. Note that get_property will never return a NULL value, regardless of the internal value. Fixes: #15840 --- demux/demux_lavf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index da095dec6b1dd..f303fd9782794 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -438,7 +438,7 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check) const AVInputFormat *forced_format = NULL; const char *format = lavfdopts->format; - if (!format) + if (!format || !format[0]) format = s->lavf_type; if (!format) format = avdevice_format;