1
mirror of https://github.com/mpv-player/mpv synced 2024-09-09 01:16:56 +02:00

demux: use seekable cache for network by default, bump prefetch limit

The option for enabling it has now an "auto" choice, which is the
default, and which will enable it if the media is thought to be via
network or if the stream cache is enabled (same logic as --cache-secs).

Also bump the --cache-secs default from 10 to 120.
This commit is contained in:
wm4 2017-11-10 16:30:43 +01:00
parent 618b8a33e5
commit 1b0dc7d169
2 changed files with 18 additions and 8 deletions

View File

@ -2876,8 +2876,8 @@ Demuxer
See ``--list-options`` for defaults and value range.
``--demuxer-seekable-cache=<yes|no>``
This controls whether seeking can use the demuxer cache (default: no). If
``--demuxer-seekable-cache=<yes|no|auto>``
This controls whether seeking can use the demuxer cache (default: auto). If
enabled, short seek offsets will not trigger a low level demuxer seek
(which means for example that slow network round trips or FFmpeg seek bugs
can be avoided). If a seek cannot happen within the cached range, a low
@ -2890,6 +2890,10 @@ Demuxer
start or after the end of the file. This option is experimental - thus
disabled, and bugs are to be expected.
The special value ``auto`` means ``yes`` in the same situation as
``--cache-secs`` is used (i.e. when the stream appears to be a network
stream or the stream cache is enabled).
``--demuxer-thread=<yes|no>``
Run the demuxer in a separate thread, and let it prefetch a certain amount
of packets (default: yes). Having this enabled may lead to smoother
@ -3818,7 +3822,7 @@ Cache
``--cache-secs=<seconds>``
How many seconds of audio/video to prefetch if the cache is active. This
overrides the ``--demuxer-readahead-secs`` option if and only if the cache
is enabled and the value is larger. (Default: 10.)
is enabled and the value is larger. (Default: 120.)
``--cache-pause``, ``--no-cache-pause``
Whether the player should automatically pause when the cache runs low,

View File

@ -104,7 +104,8 @@ const struct m_sub_options demux_conf = {
OPT_FLAG("force-seekable", force_seekable, 0),
OPT_DOUBLE("cache-secs", min_secs_cache, M_OPT_MIN, .min = 0),
OPT_FLAG("access-references", access_references, 0),
OPT_FLAG("demuxer-seekable-cache", seekable_cache, 0),
OPT_CHOICE("demuxer-seekable-cache", seekable_cache, 0,
({"auto", -1}, {"no", 0}, {"yes", 1})),
OPT_FLAG("sub-create-cc-track", create_ccs, 0),
{0}
},
@ -113,7 +114,8 @@ const struct m_sub_options demux_conf = {
.max_bytes = 400 * 1024 * 1024,
.max_bytes_bw = 400 * 1024 * 1024,
.min_secs = 1.0,
.min_secs_cache = 10.0,
.min_secs_cache = 120.0,
.seekable_cache = -1,
.access_references = 1,
},
};
@ -155,7 +157,7 @@ struct demux_internal {
double min_secs;
int max_bytes;
int max_bytes_bw;
int seekable_cache;
bool seekable_cache;
// At least one decoder actually requested data since init or the last seek.
// Do this to allow the decoder thread to select streams before starting.
@ -1947,7 +1949,6 @@ static struct demuxer *open_given_type(struct mpv_global *global,
.min_secs = opts->min_secs,
.max_bytes = opts->max_bytes,
.max_bytes_bw = opts->max_bytes_bw,
.seekable_cache = opts->seekable_cache,
.initial_state = true,
};
pthread_mutex_init(&in->lock, NULL);
@ -2016,8 +2017,13 @@ static struct demuxer *open_given_type(struct mpv_global *global,
}
}
}
if (demuxer->is_network || stream->caching)
int seekable = opts->seekable_cache;
if (demuxer->is_network || stream->caching) {
in->min_secs = MPMAX(in->min_secs, opts->min_secs_cache);
if (seekable < 0)
seekable = 1;
}
in->seekable_cache = seekable == 1;
return demuxer;
}