diff mbox

[FFmpeg-devel] FFplay: progress bar feature proposal

Message ID 3952131492087693@web47g.yandex.ru
State Superseded
Headers show

Commit Message

Raymond Pierce April 13, 2017, 12:48 p.m. UTC
Hi. Currently FFplay has no visible progress bar and it is hard to tell 
where a stream is currently positioned. So if one wants, for example, to rewind 
a little back relative to current position using right mouse click it is always 
guessing and trying.

I propose very simple 1-pixel progress bar which can be turned on or off during 
playback by pressing a button (I use 'L', from 'line'). By default the bar 
is off.

I choose bright green color (#00ff00) for the part to the left of a current
position and pure black for the part to the right.

You can see how it looks on the attached image.

Draft patch is applied. One global variable ('static int show_progress_line') 
and one function ('static void video_progress_line_display(VideoState *is)') 
have been added. Also the existing 'video_display()' function has been moved
below 'get_master_clock()' as the latter is used in the new function.

What do you think?

Comments

Steven Liu April 13, 2017, 2:32 p.m. UTC | #1
2017-04-13 20:48 GMT+08:00 Raymond Pierce <ray1110000@yandex.com>:

> Hi. Currently FFplay has no visible progress bar and it is hard to tell
> where a stream is currently positioned. So if one wants, for example, to
> rewind
> a little back relative to current position using right mouse click it is
> always
> guessing and trying.
>
> I propose very simple 1-pixel progress bar which can be turned on or off
> during
> playback by pressing a button (I use 'L', from 'line'). By default the bar
> is off.
>
> I choose bright green color (#00ff00) for the part to the left of a current
> position and pure black for the part to the right.
>
> You can see how it looks on the attached image.
>
> Draft patch is applied. One global variable ('static int
> show_progress_line')
> and one function ('static void video_progress_line_display(VideoState
> *is)')
> have been added. Also the existing 'video_display()' function has been
> moved
> below 'get_master_clock()' as the latter is used in the new function.
>
> What do you think?
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
git commit -a
git format-patch -s -1

You should use the command looks like the above git command to make patch
diff mbox

Patch

--- ffplay.c	2017-04-12 11:46:21.543322000 +0500
+++ ffplay.c	2017-04-12 14:26:47.693278504 +0500
@@ -344,6 +344,7 @@  static const char *video_codec_name;
 double rdftspeed = 0.02;
 static int64_t cursor_last_shown;
 static int cursor_hidden = 0;
+static int show_progress_line = 0;
 #if CONFIG_AVFILTER
 static const char **vfilters_list = NULL;
 static int nb_vfilters = 0;
@@ -1299,21 +1300,6 @@  static int video_open(VideoState *is)
     return 0;
 }
 
-/* display the current picture, if any */
-static void video_display(VideoState *is)
-{
-    if (!window)
-        video_open(is);
-
-    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
-    SDL_RenderClear(renderer);
-    if (is->audio_st && is->show_mode != SHOW_MODE_VIDEO)
-        video_audio_display(is);
-    else if (is->video_st)
-        video_image_display(is);
-    SDL_RenderPresent(renderer);
-}
-
 static double get_clock(Clock *c)
 {
     if (*c->queue_serial != c->serial)
@@ -1513,6 +1499,37 @@  static void update_video_pts(VideoState
     sync_clock_to_slave(&is->extclk, &is->vidclk);
 }
 
+static void video_progress_line_display(VideoState *is) {
+    double d = is->ic->duration / 1.0e6;
+    if (d > 0) {
+        double t = get_master_clock(is);
+        int w = is->width * t / d;
+        SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
+        fill_rectangle(0, is->height-1, w, 1);
+        SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+        fill_rectangle(w, is->height-1, is->width-w, 1);
+    } else {
+        show_progress_line = 0;
+    }
+}
+
+/* display the current picture, if any */
+static void video_display(VideoState *is)
+{
+    if (!window)
+        video_open(is);
+
+    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
+    SDL_RenderClear(renderer);
+    if (is->audio_st && is->show_mode != SHOW_MODE_VIDEO)
+        video_audio_display(is);
+    else if (is->video_st)
+        video_image_display(is);
+    if (show_progress_line)
+        video_progress_line_display(is);
+    SDL_RenderPresent(renderer);
+}
+
 /* called to display each frame */
 static void video_refresh(void *opaque, double *remaining_time)
 {
@@ -3265,6 +3282,9 @@  static void event_loop(VideoState *cur_s
                 toggle_audio_display(cur_stream);
 #endif
                 break;
+            case SDLK_l:
+                show_progress_line = !show_progress_line;
+                break;
             case SDLK_PAGEUP:
                 if (cur_stream->ic->nb_chapters <= 1) {
                     incr = 600.0;
@@ -3543,6 +3563,7 @@  static const OptionDef options[] = {
 #endif
     { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, { &rdftspeed }, "rdft speed", "msecs" },
     { "showmode", HAS_ARG, { .func_arg = opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
+    { "progress", OPT_BOOL, { &show_progress_line}, "show progress line at the bottom", ""},
     { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, { .func_arg = opt_default }, "generic catch all option", "" },
     { "i", OPT_BOOL, { &dummy}, "read specified file", "input_file"},
     { "codec", HAS_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
@@ -3587,6 +3608,7 @@  void show_help_default(const char *opt,
            "c                   cycle program\n"
            "w                   cycle video filters or show modes\n"
            "s                   activate frame-step mode\n"
+           "l                   toggle progress line at the bottom\n"
            "left/right          seek backward/forward 10 seconds\n"
            "down/up             seek backward/forward 1 minute\n"
            "page down/page up   seek backward/forward 10 minutes\n"