[MPlayer-dev-eng] [PATCH] demux_lavf: add an option to use the new seek API.

Nicolas George nicolas.george at normalesup.org
Sun Apr 7 19:52:36 CEST 2013


---
 DOCS/man/en/mplayer.1   |    4 ++++
 libmpdemux/demux_lavf.c |    6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index 9000f34..500c9fb 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -11758,6 +11758,10 @@ This is the raw binary data of the key converted to a hexadecimal string.
 Prefix prepended to URL passed to libavformat.
 The default is "mp:".
 .
+.TP
+.B newseekapi=<value>
+If set to 1, enable using libavformat's new seek API.
+.
 .
 .SS FFmpeg libavformat muxers (\-lavfopts) (also see \-of lavf)
 .
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index ef623e8..a14a560 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -51,6 +51,7 @@
 
 static unsigned int opt_probesize = 0;
 static unsigned int opt_analyzeduration = 0;
+static unsigned int opt_newseekapi = 0;
 static char *opt_format;
 static char *opt_cryptokey;
 static char *opt_avopt = NULL;
@@ -62,6 +63,7 @@ const m_option_t lavfdopts_conf[] = {
 	{"analyzeduration",    &(opt_analyzeduration),    CONF_TYPE_INT,       CONF_RANGE,  0,       INT_MAX, NULL},
 	{"cryptokey", &(opt_cryptokey), CONF_TYPE_STRING,       0,  0,       0, NULL},
 	{"urlprefix", &(opt_urlprefix), CONF_TYPE_STRING, M_OPT_MIN,0,       0, NULL},
+        {"newseekapi", &(opt_newseekapi), CONF_TYPE_INT, CONF_RANGE, 0,      1, NULL},
         {"o",                  &opt_avopt,                CONF_TYPE_STRING,    0,           0,             0, NULL},
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
@@ -704,6 +706,10 @@ static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, float audio
     } else {
       priv->last_pts += rel_seek_secs * AV_TIME_BASE;
     }
+    if (opt_newseekapi) {
+        avformat_seek_file(priv->avfc, -1, INT64_MIN, priv->last_pts, INT64_MAX, avsflags);
+        return;
+    }
     if (av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags) < 0) {
         avsflags ^= AVSEEK_FLAG_BACKWARD;
         av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags);
-- 
1.7.10.4



More information about the MPlayer-dev-eng mailing list