summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/options.rst14
-rw-r--r--demux/demux.c6
-rw-r--r--demux/demux.h5
-rw-r--r--options/options.c4
-rw-r--r--options/options.h2
6 files changed, 27 insertions, 6 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 9eb3de3048..d2f186d6d7 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -21,6 +21,8 @@ Interface changes
--- mpv 0.10.0 will be released ---
- remove --demuxer-readahead-packets and --demuxer-readahead-bytes
+ add --demuxer-max-packets and --demuxer-max-bytes
+ (the new options are not replacement and have very different semantics)
- change "video-aspect" property: always settable, even if no video is
running; always return the override - if no override is set, return
the video's aspect ratio
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index f86e489db1..b5587ccfe6 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2229,6 +2229,20 @@ Demuxer
``--demuxer-rawvideo-size=<value>``
Frame size in bytes when using ``--demuxer=rawvideo``.
+``--demuxer-max-packets=<packets>``, ``--demuxer-max-bytes=<bytes>``
+ This controls how much the demuxer is allowed to buffer ahead. The demuxer
+ will normally try to read ahead as much as necessary, or as much is
+ requested with ``--demuxer-readahead-secs``. The ``--demuxer-max-...``
+ options can be used to restrict the maximum readahead. This limits excessive
+ readahead in case of broken files or desynced playback. The demuxer will
+ stop reading additional packets as soon as one of the limits is reached.
+ (The limits still can be slightly overstepped due to technical reasons.)
+
+ Set these limits highher if you get a packet queue overflow warning, and
+ you think normal playback would be possible with a larger packet queue.
+
+ See ``--list-options`` for defaults and value range.
+
``--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
diff --git a/demux/demux.c b/demux/demux.c
index 55dfd259da..fedc533926 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -112,6 +112,8 @@ struct demux_internal {
bool idle;
bool autoselect;
double min_secs;
+ int max_packs;
+ int max_bytes;
bool tracks_switched; // thread needs to inform demuxer of this
@@ -391,7 +393,7 @@ static bool read_packet(struct demux_internal *in)
}
MP_DBG(in, "packets=%zd, bytes=%zd, active=%d, more=%d\n",
packs, bytes, active, read_more);
- if (packs >= MAX_PACKS || bytes >= MAX_PACK_BYTES) {
+ if (packs >= in->max_packs || bytes >= in->max_bytes) {
if (!in->warned_queue_overflow) {
in->warned_queue_overflow = true;
MP_ERR(in, "Too many packets in the demuxer packet queues:\n");
@@ -957,6 +959,8 @@ static struct demuxer *open_given_type(struct mpv_global *global,
.d_buffer = talloc(demuxer, struct demuxer),
.d_user = demuxer,
.min_secs = demuxer->opts->demuxer_min_secs,
+ .max_packs = demuxer->opts->demuxer_max_packs,
+ .max_bytes = demuxer->opts->demuxer_max_bytes,
};
pthread_mutex_init(&in->lock, NULL);
pthread_cond_init(&in->wakeup, NULL);
diff --git a/demux/demux.h b/demux/demux.h
index 22c7323ef1..710073d26c 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -30,11 +30,6 @@
#include "packet.h"
#include "stheader.h"
-// Maximum total size of packets queued - if larger, no new packets are read,
-// and the demuxer pretends EOF was reached.
-#define MAX_PACKS 16000
-#define MAX_PACK_BYTES (400 * 1024 * 1024)
-
// DEMUXER control commands/answers
#define DEMUXER_CTRL_NOTIMPL -1
#define DEMUXER_CTRL_DONTKNOW 0
diff --git a/options/options.c b/options/options.c
index 93f7b4a45e..1528f06ee5 100644
--- a/options/options.c
+++ b/options/options.c
@@ -242,6 +242,8 @@ const m_option_t mp_opts[] = {
OPT_STRING("sub-demuxer", sub_demuxer_name, 0),
OPT_FLAG("demuxer-thread", demuxer_thread, 0),
OPT_DOUBLE("demuxer-readahead-secs", demuxer_min_secs, M_OPT_MIN, .min = 0),
+ OPT_INTRANGE("demuxer-max-packets", demuxer_max_packs, 0, 0, INT_MAX),
+ OPT_INTRANGE("demuxer-max-bytes", demuxer_max_bytes, 0, 0, INT_MAX),
OPT_FLAG("force-seekable", force_seekable, 0),
@@ -718,6 +720,8 @@ const struct MPOpts mp_default_opts = {
.back_buffer = 75000,
.file_max = 1024 * 1024,
},
+ .demuxer_max_packs = 16000,
+ .demuxer_max_bytes = 400 * 1024 * 1024,
.demuxer_thread = 1,
.demuxer_min_secs = 1.0,
.network_rtsp_transport = 2,
diff --git a/options/options.h b/options/options.h
index 677b23f92e..4382831883 100644
--- a/options/options.h
+++ b/options/options.h
@@ -195,6 +195,8 @@ typedef struct MPOpts {
char **audio_files;
char *demuxer_name;
+ int demuxer_max_packs;
+ int demuxer_max_bytes;
int demuxer_thread;
double demuxer_min_secs;
char *audio_demuxer_name;