diff mbox

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

Message ID 76d7a3d8-a786-a156-b745-250cc0ad9a9a@gmail.com
State Accepted
Commit 1a4a8df249426c85ba6c96ef5ab022afaaf4dc8f
Headers show

Commit Message

Gyan Sept. 3, 2018, 5:33 a.m. UTC
On 02-09-2018 02:57 PM, Marton Balint wrote:
> 
> 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.

v3: option renamed; sign guard removed.

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

At present, left and right keys are hardcoded to seek by 10 seconds.
---
 doc/ffplay.texi  | 2 ++
 fftools/ffplay.c | 8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Gyan Sept. 5, 2018, 4:05 p.m. UTC | #1
On 03-09-2018 11:03 AM, Gyan Doshi wrote:
> On 02-09-2018 02:57 PM, Marton Balint wrote:

>>
>> 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.
> 
> v3: option renamed; sign guard removed.
> 
> Gyan
> 

Ping.
Marton Balint Sept. 5, 2018, 4:22 p.m. UTC | #2
On Wed, 5 Sep 2018, Gyan Doshi wrote:

> On 03-09-2018 11:03 AM, Gyan Doshi wrote:
>> On 02-09-2018 02:57 PM, Marton Balint wrote:
>
>>>
>>> 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.
>> 
>> v3: option renamed; sign guard removed.
>> 
>> Gyan
>> 
>
> Ping.

LGTM, thanks.

Marton
Gyan Sept. 5, 2018, 6:25 p.m. UTC | #3
On 05-09-2018 09:52 PM, Marton Balint wrote:
> 
> 
> On Wed, 5 Sep 2018, Gyan Doshi wrote:

>>>
>>
>> Ping.
> 
> LGTM, thanks.

Pushed as 1a4a8df249426c85ba6c96ef5ab022afaaf4dc8f

Thanks,
Gyan
diff mbox

Patch

diff --git a/doc/ffplay.texi b/doc/ffplay.texi
index c95956ea17..dcb86ce13c 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_interval
+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 5d9121e5b7..e375a32ec2 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;
@@ -3343,10 +3344,10 @@  static void event_loop(VideoState *cur_stream)
                 seek_chapter(cur_stream, -1);
                 break;
             case SDLK_LEFT:
-                incr = -10.0;
+                incr = seek_interval ? -seek_interval : -10.0;
                 goto do_seek;
             case SDLK_RIGHT:
-                incr = 10.0;
+                incr = seek_interval ? seek_interval : 10.0;
                 goto do_seek;
             case SDLK_UP:
                 incr = 60.0;
@@ -3582,6 +3583,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_interval", 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" },
@@ -3652,7 +3654,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_interval 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"