summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-14 13:46:03 +0100
committerwm4 <wm4@nowhere>2019-11-14 13:46:03 +0100
commit5a99015acf184a2989ea7ebf50ab2c990be41125 (patch)
tree08448e6073228a7c2eb3fe5790e1f6389d7ca329
parentac7f67b3f23a63e463fb881d960bc8f31a230292 (diff)
downloadmpv-5a99015acf184a2989ea7ebf50ab2c990be41125.tar.bz2
mpv-5a99015acf184a2989ea7ebf50ab2c990be41125.tar.xz
stream_lavf: set --network-timeout to 60 seconds by default
Until now, we've made FFmpeg use the default network timeout - which is apparently infinite. I don't know if this was changed at some point, although it seems likely, as I was sure there was a more useful default. For most use cases, a smaller timeout is more useful (for example recording something in the background), so force a timeout of 1 minute. See: #5793
-rw-r--r--DOCS/man/options.rst13
-rw-r--r--demux/demux_lavf.c3
-rw-r--r--stream/stream.h1
-rw-r--r--stream/stream_lavf.c18
4 files changed, 23 insertions, 12 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index d4e3bb5c7c..6a73ac7a85 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4280,9 +4280,10 @@ Network
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.
+ Specify the network timeout in seconds (default: 60 seconds). This affects
+ at least HTTP. The special value 0 uses the FFmpeg/Libav defaults. If a
+ protocol is used which does not support timeouts, this option is silently
+ ignored.
.. warning::
@@ -4291,8 +4292,10 @@ Network
option accept different units (seconds instead of microseconds, causing
mpv to pass it huge values), it will also overflow FFmpeg internal
calculations. The worst is that merely setting the option will put RTSP
- into listening mode, which breaks any client uses. Do not use this
- option with RTSP URLs.
+ into listening mode, which breaks any client uses. At time of this
+ writing, the fix was not made effective yet. For this reason, this
+ option is ignored (or should be ignored) on RTSP URLs. You can still
+ set the timeout option directly with ``--demuxer-lavf-o``.
``--rtsp-transport=<lavf|udp|tcp|http>``
Select RTSP transport method (default: tcp). This selects the underlying
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 9ac6495f15..5153bfe42f 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -925,7 +925,8 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
AVDictionary *dopts = NULL;
if ((priv->avif_flags & AVFMT_NOFILE) || priv->format_hack.no_stream) {
- mp_setup_av_network_options(&dopts, demuxer->global, demuxer->log);
+ mp_setup_av_network_options(&dopts, priv->avif->name,
+ demuxer->global, demuxer->log);
// This might be incorrect.
demuxer->seekable = true;
} else {
diff --git a/stream/stream.h b/stream/stream.h
index d054e54914..aa764818b7 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -243,6 +243,7 @@ char *mp_file_get_path(void *talloc_ctx, bstr url);
// stream_lavf.c
struct AVDictionary;
void mp_setup_av_network_options(struct AVDictionary **dict,
+ const char *target_fmt,
struct mpv_global *global,
struct mp_log *log);
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index 5359d8d7d4..604535c431 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -69,6 +69,7 @@ const struct m_sub_options stream_lavf_conf = {
.size = sizeof(struct stream_lavf_params),
.defaults = &(const struct stream_lavf_params){
.useragent = (char *)mpv_version,
+ .timeout = 60,
},
};
@@ -180,8 +181,8 @@ static int interrupt_cb(void *ctx)
static const char * const prefix[] = { "lavf://", "ffmpeg://" };
-void mp_setup_av_network_options(AVDictionary **dict, struct mpv_global *global,
- struct mp_log *log)
+void mp_setup_av_network_options(AVDictionary **dict, const char *target_fmt,
+ struct mpv_global *global, struct mp_log *log)
{
void *temp = talloc_new(NULL);
struct stream_lavf_params *opts =
@@ -220,10 +221,15 @@ void mp_setup_av_network_options(AVDictionary **dict, struct mpv_global *global,
av_dict_set(dict, "headers", cust_headers, 0);
av_dict_set(dict, "icy", "1", 0);
// So far, every known protocol uses microseconds for this
+ // Except rtsp.
if (opts->timeout > 0) {
- char buf[80];
- snprintf(buf, sizeof(buf), "%lld", (long long)(opts->timeout * 1e6));
- av_dict_set(dict, "timeout", buf, 0);
+ if (target_fmt && strcmp(target_fmt, "rtsp") == 0) {
+ mp_verbose(log, "Broken FFmpeg RTSP API => not setting timeout.\n");
+ } else {
+ char buf[80];
+ snprintf(buf, sizeof(buf), "%lld", (long long)(opts->timeout * 1e6));
+ av_dict_set(dict, "timeout", buf, 0);
+ }
}
if (opts->http_proxy && opts->http_proxy[0])
av_dict_set(dict, "http_proxy", opts->http_proxy, 0);
@@ -292,7 +298,7 @@ static int open_f(stream_t *stream)
av_dict_set(&dict, "reconnect", "1", 0);
av_dict_set(&dict, "reconnect_delay_max", "7", 0);
- mp_setup_av_network_options(&dict, stream->global, stream->log);
+ mp_setup_av_network_options(&dict, NULL, stream->global, stream->log);
AVIOInterruptCB cb = {
.callback = interrupt_cb,