aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst5
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
-rw-r--r--stream/stream_lavf.c3
4 files changed, 11 insertions, 0 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 91c10f187b..83bb05cdad 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -3135,6 +3135,11 @@ Network
``--referrer=<string>``
Specify a referrer path or URL for HTTP requests.
+``--network-timeout=<seconds>``
+ Specify the network timeout in seconds. This affects at least HTTP. The
+ special value 0 (default) uses the FFmpeg/Libav defaults. If a protocol
+ is used which does not support timeouts, this option is silently ignored.
+
``--rtsp-transport=<lavf|udp|tcp|http>``
Select RTSP transport method (default: tcp). This selects the underlying
network transport when playing ``rtsp://...`` URLs. The value ``lavf``
diff --git a/options/options.c b/options/options.c
index a7f6ab193f..55b444a983 100644
--- a/options/options.c
+++ b/options/options.c
@@ -173,6 +173,7 @@ const m_option_t mp_opts[] = {
{"http", 3})),
OPT_FLAG("tls-verify", network_tls_verify, 0),
OPT_STRING("tls-ca-file", network_tls_ca_file, M_OPT_FILE),
+ OPT_DOUBLE("network-timeout", network_timeout, M_OPT_MIN, .min = 0),
// ------------------------- demuxer options --------------------
@@ -730,6 +731,7 @@ const struct MPOpts mp_default_opts = {
.demuxer_min_bytes = 0,
.demuxer_min_secs = 0.2,
.network_rtsp_transport = 2,
+ .network_timeout = 0.0,
.hls_bitrate = 2,
.demuxer_min_secs_cache = 2,
.cache_pausing = 1,
diff --git a/options/options.h b/options/options.h
index 6c74fd3ed7..c558176940 100644
--- a/options/options.h
+++ b/options/options.h
@@ -274,6 +274,7 @@ typedef struct MPOpts {
char **network_http_header_fields;
int network_tls_verify;
char *network_tls_ca_file;
+ double network_timeout;
struct tv_params *tv_params;
struct pvr_params *stream_pvr_opts;
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index fd83202632..a121cd5af4 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -181,6 +181,9 @@ void mp_setup_av_network_options(AVDictionary **dict, struct mpv_global *global,
if (strlen(cust_headers))
av_dict_set(dict, "headers", cust_headers, 0);
av_dict_set(dict, "icy", "1", 0);
+ // So far, every known protocol uses microseconds for this
+ if (opts->network_timeout > 0)
+ av_dict_set_int(dict, "timeout", opts->network_timeout * 1e6, 0);
mp_set_avdict(dict, opts->stream_lavf_opts->avopts);