diff options
-rw-r--r-- | DOCS/man/options.rst | 10 | ||||
-rw-r--r-- | demux/demux.c | 16 |
2 files changed, 18 insertions, 8 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 64e467e11f..2093f51b8c 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -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, diff --git a/demux/demux.c b/demux/demux.c index 2a46ac730f..b66ed9abbb 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -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; } |