[FFmpeg-devel] ffplay: add option to allow custom jump interval

Submitted by Gyan on Sept. 1, 2018, 7:05 a.m.

Details

Message ID a7a5de43-ef1a-2938-d43e-203e2391f928@gmail.com
State New
Headers show

Commit Message

Gyan Sept. 1, 2018, 7:05 a.m.
From aab52de703302d26d0bd83fb28eb1a033fa57d14 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg@gyani.pro>
Date: Sat, 1 Sep 2018 11:33:17 +0530
Subject: [PATCH] ffplay: add option to allow custom jump interval

At present, left and right keys are hardcoded to jump by 10 seconds.
Added option allows users to set a custom interval, in seconds.
---
 doc/ffplay.texi  | 2 ++
 fftools/ffplay.c | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Marton Balint Sept. 1, 2018, 4:55 p.m.
On Sat, 1 Sep 2018, Gyan Doshi wrote:

> From aab52de703302d26d0bd83fb28eb1a033fa57d14 Mon Sep 17 00:00:00 2001
> From: Gyan Doshi <ffmpeg@gyani.pro>
> Date: Sat, 1 Sep 2018 11:33:17 +0530
> Subject: [PATCH] ffplay: add option to allow custom jump interval
>
> At present, left and right keys are hardcoded to jump by 10 seconds.
> Added option allows users to set a custom interval, in seconds.
> ---
> doc/ffplay.texi  | 2 ++
> fftools/ffplay.c | 8 +++++---
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
> index c95956ea17..5dbbee4e02 100644
> --- a/doc/ffplay.texi
> +++ b/doc/ffplay.texi
> @@ -60,6 +60,8 @@ Play @var{duration} seconds of audio/video.
> see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
> @item -bytes
> Seek by bytes.
> +@item -jump
> +Set custom interval, in seconds, for jumping using left/right keys. Default is 10 seconds.

In the descriptive text write "seeking" instead of jumping.

> @item -nodisp
> Disable graphical display.
> @item -noborder
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 368e262123..83eef17797 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -319,6 +319,7 @@ static int video_disable;
> static int subtitle_disable;
> static const char* wanted_stream_spec[AVMEDIA_TYPE_NB] = {0};
> static int seek_by_bytes = -1;
> +static float jump_interval = 0;

why not make this = 10.0 by default? And change the code below 
accordingly.

> static int display_disable;
> static int borderless;
> static int startup_volume = 100;
> @@ -3341,10 +3342,10 @@ static void event_loop(VideoState *cur_stream)
>                 seek_chapter(cur_stream, -1);
>                 break;
>             case SDLK_LEFT:
> -                incr = -10.0;
> +                incr = jump_interval > 0 ? -jump_interval : -10.0;
>                 goto do_seek;
>             case SDLK_RIGHT:
> -                incr = 10.0;
> +                incr = jump_interval > 0 ? jump_interval : 10.0;
>                 goto do_seek;
>             case SDLK_UP:
>                 incr = 60.0;
> @@ -3580,6 +3581,7 @@ static const OptionDef options[] = {
>     { "ss", HAS_ARG, { .func_arg = opt_seek }, "seek to a given position in seconds", "pos" },
>     { "t", HAS_ARG, { .func_arg = opt_duration }, "play  \"duration\" seconds of audio/video", "duration" },
>     { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" },
> +    { "jump", OPT_FLOAT | HAS_ARG, { &jump_interval }, "set jump interval for left/right keys, in seconds", "seconds" },
>     { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" },
>     { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
>     { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
> @@ -3650,7 +3652,7 @@ void show_help_default(const char *opt, const char *arg)
>            "c                   cycle program\n"
>            "w                   cycle video filters or show modes\n"
>            "s                   activate frame-step mode\n"
> -           "left/right          seek backward/forward 10 seconds\n"
> +           "left/right          seek backward/forward 10 seconds or to custom interval if -jump is set\n"
>            "down/up             seek backward/forward 1 minute\n"
>            "page down/page up   seek backward/forward 10 minutes\n"
>            "right mouse click   seek to percentage in file corresponding to fraction of width\n"

Regards,
Marton

Patch hide | download patch | download mbox

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index c95956ea17..5dbbee4e02 100644
--- a/doc/ffplay.texi
+++ b/doc/ffplay.texi
@@ -60,6 +60,8 @@  Play @var{duration} seconds of audio/video.
 see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
 @item -bytes
 Seek by bytes.
+@item -jump
+Set custom interval, in seconds, for jumping using left/right keys. Default is 10 seconds.
 @item -nodisp
 Disable graphical display.
 @item -noborder
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 368e262123..83eef17797 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -319,6 +319,7 @@  static int video_disable;
 static int subtitle_disable;
 static const char* wanted_stream_spec[AVMEDIA_TYPE_NB] = {0};
 static int seek_by_bytes = -1;
+static float jump_interval = 0;
 static int display_disable;
 static int borderless;
 static int startup_volume = 100;
@@ -3341,10 +3342,10 @@  static void event_loop(VideoState *cur_stream)
                 seek_chapter(cur_stream, -1);
                 break;
             case SDLK_LEFT:
-                incr = -10.0;
+                incr = jump_interval > 0 ? -jump_interval : -10.0;
                 goto do_seek;
             case SDLK_RIGHT:
-                incr = 10.0;
+                incr = jump_interval > 0 ? jump_interval : 10.0;
                 goto do_seek;
             case SDLK_UP:
                 incr = 60.0;
@@ -3580,6 +3581,7 @@  static const OptionDef options[] = {
     { "ss", HAS_ARG, { .func_arg = opt_seek }, "seek to a given position in seconds", "pos" },
     { "t", HAS_ARG, { .func_arg = opt_duration }, "play  \"duration\" seconds of audio/video", "duration" },
     { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" },
+    { "jump", OPT_FLOAT | HAS_ARG, { &jump_interval }, "set jump interval for left/right keys, in seconds", "seconds" },
     { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" },
     { "noborder", OPT_BOOL, { &borderless }, "borderless window" },
     { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" },
@@ -3650,7 +3652,7 @@  void show_help_default(const char *opt, const char *arg)
            "c                   cycle program\n"
            "w                   cycle video filters or show modes\n"
            "s                   activate frame-step mode\n"
-           "left/right          seek backward/forward 10 seconds\n"
+           "left/right          seek backward/forward 10 seconds or to custom interval if -jump is set\n"
            "down/up             seek backward/forward 1 minute\n"
            "page down/page up   seek backward/forward 10 minutes\n"
            "right mouse click   seek to percentage in file corresponding to fraction of width\n"