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

Submitted by Gyan on Sept. 2, 2018, 4:51 a.m.

Details

Message ID fd646524-003e-102d-e352-a25144959bfb@gmail.com
State New
Headers show

Commit Message

Gyan Sept. 2, 2018, 4:51 a.m.
On 01-09-2018 10:25 PM, Marton Balint wrote:
> 
> 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.

Changed 'jump' to 'seek' throughout.

Haven't changed code much, kept basic protection against invalid input 
(val < 0)

Gyan
From abd6b2616ec2caf115dcdf05fba6be0a3c80a17a Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg@gyani.pro>
Date: Sat, 1 Sep 2018 11:33:17 +0530
Subject: [PATCH v2] ffplay: add option to allow custom seek interval

At present, left and right keys are hardcoded to seek 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. 2, 2018, 9:27 a.m.
On Sun, 2 Sep 2018, Gyan Doshi wrote:

> On 01-09-2018 10:25 PM, Marton Balint wrote:
>> 
>> 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.
>
> Changed 'jump' to 'seek' throughout.

Change the option name to seek_interval then, -seek alone seems a bit 
confusing to me because it might mean to do initial seek in the input 
before playing the file.

>
> Haven't changed code much, kept basic protection against invalid input (val < 
> 0)

I don't think the guards are necessary, it might make sense for somebody 
to reverse the meaning of left and right keys, therefore use a negative 
value.

Thanks,
Marton

Patch hide | download patch | download mbox

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index c95956ea17..8dd7803e97 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 -seek
+Set custom interval, in seconds, for seeking 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..8409952f3b 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 seek_interval = 10;
 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 = seek_interval ? -FFABS(seek_interval) : -10.0;
                 goto do_seek;
             case SDLK_RIGHT:
-                incr = 10.0;
+                incr = seek_interval ? FFABS(seek_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" },
+    { "seek", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek 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 -seek 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"