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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Apr 9 22:28:02 CEST 2013


On 07.04.2013, at 19:52, Nicolas George <nicolas.george at normalesup.org> wrote:
> ---
> 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;
> +    }

What is the point of that? With those settings I believe seeking will work very badly (in particular, in files with few keyframes seeking forward will actually end up seeking backwards and then get stuck).
Or in other words, at the very least for relative seeks you should set either min or max to the reference time stamp (possibly with a small offset to make sure we never get stuck).
Then, to keep old behaviour you should try a seek with neither min or max set if that fails.


More information about the MPlayer-dev-eng mailing list