From aaa42f82dca51ef51d6cfe682c807bbec30940e7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 19 Mar 2015 16:41:48 +0100 Subject: stream_lavf: workaround broken rtmp "timeout" option The libavformat rtmp protocol's "timeout" option has two problems: 1) Unlike all other protocols, it's in seconds and not microseconds 2) It enables "listen" mode, which breaks playback Make the --network-timeout do nothing in the rtmp case. Fixes #1704. --- stream/stream_lavf.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index 1b9f7363ae..48a9aa358d 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -262,6 +262,13 @@ static int open_f(stream_t *stream) filename = normalize_url(stream, filename); + if (strncmp(filename, "rtmp", 4) == 0) { + stream->demuxer = "lavf"; + stream->lavf_type = "flv"; + // Setting timeout enables listen mode - force it to disabled. + av_dict_set(&dict, "timeout", "0", 0); + } + int err = avio_open2(&avio, filename, flags, &cb, &dict); if (err < 0) { if (err == AVERROR_PROTOCOL_NOT_FOUND) @@ -280,10 +287,6 @@ static int open_f(stream_t *stream) } } - if (strncmp(filename, "rtmp", 4) == 0) { - stream->demuxer = "lavf"; - stream->lavf_type = "flv"; - } stream->priv = avio; stream->seekable = avio->seekable; stream->seek = stream->seekable ? seek : NULL; -- cgit v1.2.3