From b0f7a26f1a6dc061db0a60908842371e7a010db2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 22 Sep 2013 02:40:29 +0200 Subject: network: fix rtsp playback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, libavformat uses UDP for rtsp playback. This doesn't work very well. Apparently the reason is that the buffer sizes libavformat chooses for UDP are way too small, and switching to TCP gets rid of this issue entirely (thanks go to Reimar Döffinger for figuring this out). In theory, you can set buffer sizes as libavformat options, but that doesn't seem to help. Add an option to select the rtsp transport, and make TCP the default. Also remove an outdated comment from stream.c. --- demux/demux_lavf.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'demux') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index dbe16a76b9..1e071f20e2 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -603,12 +603,33 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) avfc->pb = priv->pb; } - if (avformat_open_input(&avfc, priv->filename, priv->avif, NULL) < 0) { + AVDictionary *dopts = NULL; + + if (matches_avinputformat_name(priv, "rtsp")) { + const char *transport = NULL; + switch (opts->network_rtsp_transport) { + case 1: transport = "udp"; break; + case 2: transport = "tcp"; break; + case 3: transport = "http"; break; + } + if (transport) + av_dict_set(&dopts, "rtsp_transport", transport, 0); + } + + if (avformat_open_input(&avfc, priv->filename, priv->avif, &dopts) < 0) { mp_msg(MSGT_HEADER, MSGL_ERR, "LAVF_header: avformat_open_input() failed\n"); + av_dict_free(&dopts); return -1; } + t = NULL; + while ((t = av_dict_get(dopts, "", t, AV_DICT_IGNORE_SUFFIX))) { + mp_msg(MSGT_OPEN, MSGL_V, "[lavf] Could not set demux option %s=%s\n", + t->key, t->value); + } + av_dict_free(&dopts); + priv->avfc = avfc; if (avformat_find_stream_info(avfc, NULL) < 0) { mp_msg(MSGT_HEADER, MSGL_ERR, -- cgit v1.2.3