mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 03:52:22 +02:00
network: fix rtsp playback
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.
This commit is contained in:
parent
ce861c9f33
commit
b0f7a26f1a
@ -1772,6 +1772,11 @@
|
||||
- ``--reset-on-next-file=""``
|
||||
Do not reset pause mode.
|
||||
|
||||
``--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``
|
||||
leaves the decision to libavformat.
|
||||
|
||||
``--saturation=<-100-100>``
|
||||
Adjust the saturation of the video signal (default: 0). You can get
|
||||
grayscale output with this option. Not supported by all video output
|
||||
|
@ -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,
|
||||
|
@ -382,6 +382,11 @@ const m_option_t mp_opts[] = {
|
||||
{"referrer", &network_referrer, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
{"cookies", &network_cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||
{"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||
OPT_CHOICE("rtsp-transport", network_rtsp_transport, 0,
|
||||
({"lavf", 0},
|
||||
{"udp", 1},
|
||||
{"tcp", 2},
|
||||
{"http", 3})),
|
||||
|
||||
// ------------------------- demuxer options --------------------
|
||||
|
||||
@ -794,6 +799,7 @@ const struct MPOpts mp_default_opts = {
|
||||
.stream_cache_min_percent = 20.0,
|
||||
.stream_cache_seek_min_percent = 50.0,
|
||||
.stream_cache_pause = 10.0,
|
||||
.network_rtsp_transport = 2,
|
||||
.chapterrange = {-1, -1},
|
||||
.edition_id = -1,
|
||||
.default_max_pts_correction = -1,
|
||||
|
@ -98,6 +98,7 @@ typedef struct MPOpts {
|
||||
int stream_cache_def_size;
|
||||
float stream_cache_min_percent;
|
||||
float stream_cache_seek_min_percent;
|
||||
int network_rtsp_transport;
|
||||
int stream_cache_pause;
|
||||
int chapterrange[2];
|
||||
int edition_id;
|
||||
|
@ -86,7 +86,7 @@ static const stream_info_t *const stream_list[] = {
|
||||
#ifdef CONFIG_CDDA
|
||||
&stream_info_cdda,
|
||||
#endif
|
||||
&stream_info_ffmpeg, // use for rstp:// before http fallback
|
||||
&stream_info_ffmpeg,
|
||||
&stream_info_avdevice,
|
||||
#ifdef CONFIG_DVBIN
|
||||
&stream_info_dvb,
|
||||
|
Loading…
Reference in New Issue
Block a user