summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-04 23:25:54 +0200
committerwm4 <wm4@nowhere>2013-08-04 23:25:54 +0200
commitcccfac47a423cbaeda04f9864c4676ed1c9d5002 (patch)
tree5de89b6851bcc04655d700c63ebf0c3e05342862
parentb53497a403d0b1453e35f02a157542f67e0c7374 (diff)
downloadmpv-cccfac47a423cbaeda04f9864c4676ed1c9d5002.tar.bz2
mpv-cccfac47a423cbaeda04f9864c4676ed1c9d5002.tar.xz
demux_lavf: make avio buffer configurable
Perhaps not very useful, but reserved for situations when a user reports awful latency and experimentation/debugging might be required to find out why or to fix it (happens often).
-rw-r--r--DOCS/man/en/options.rst6
-rw-r--r--core/options.h1
-rw-r--r--demux/demux_lavf.c14
3 files changed, 15 insertions, 6 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 7f5faa88fb..14cb2ace67 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -614,6 +614,12 @@
case of MPEG-TS this value identifies the maximum number of TS packets
to scan.
+``--demuxer-lavf-buffersize=<value>``
+ Size of the stream read buffer allocated for libavformat in bytes
+ (default: 32768). Lowering the size could lower latency. Note that
+ libavformat might reallocate the buffer internally, or not fully use all
+ of it.
+
``--demuxer-lavf-cryptokey=<hexstring>``
Encryption key the demuxer should use. This is the raw binary data of
the key converted to a hexadecimal string.
diff --git a/core/options.h b/core/options.h
index 2037d6da4b..9a8deb9e4d 100644
--- a/core/options.h
+++ b/core/options.h
@@ -216,6 +216,7 @@ typedef struct MPOpts {
int probesize;
int probescore;
float analyzeduration;
+ int buffersize;
int allow_mimetype;
char *format;
char *cryptokey;
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 11e17f949f..1654562bd9 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -51,10 +51,16 @@
#define OPT_BASE_STRUCT struct MPOpts
+// Should correspond to IO_BUFFER_SIZE in libavformat/aviobuf.c (not public)
+// libavformat (almost) always reads data in blocks of this size.
+#define BIO_BUFFER_SIZE 32768
+
const m_option_t lavfdopts_conf[] = {
OPT_INTRANGE("probesize", lavfdopts.probesize, 0, 32, INT_MAX),
OPT_STRING("format", lavfdopts.format, 0),
OPT_FLOATRANGE("analyzeduration", lavfdopts.analyzeduration, 0, 0, 3600),
+ OPT_INTRANGE("buffersize", lavfdopts.buffersize, 0, 1, 10 * 1024 * 1024,
+ OPTDEF_INT(BIO_BUFFER_SIZE)),
OPT_FLAG("allow-mimetype", lavfdopts.allow_mimetype, 0),
OPT_INTRANGE("probescore", lavfdopts.probescore, 0, 0, 100),
OPT_STRING("cryptokey", lavfdopts.cryptokey, 0),
@@ -64,10 +70,6 @@ const m_option_t lavfdopts_conf[] = {
{NULL, NULL, 0, 0, 0, 0, NULL}
};
-// Should correspond to IO_BUFFER_SIZE in libavformat/aviobuf.c (not public)
-// libavformat (almost) always reads data in blocks of this size.
-#define BIO_BUFFER_SIZE 32768
-
#define MAX_PKT_QUEUE 50
typedef struct lavf_priv {
@@ -570,10 +572,10 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (!(priv->avif->flags & AVFMT_NOFILE) &&
demuxer->stream->type != STREAMTYPE_AVDEVICE)
{
- void *buffer = av_malloc(BIO_BUFFER_SIZE);
+ void *buffer = av_malloc(lavfdopts->buffersize);
if (!buffer)
return -1;
- priv->pb = avio_alloc_context(buffer, BIO_BUFFER_SIZE, 0,
+ priv->pb = avio_alloc_context(buffer, lavfdopts->buffersize, 0,
demuxer, mp_read, NULL, mp_seek);
if (!priv->pb) {
av_free(buffer);