13.04.2017, 09:40, "Steven Liu" <lingjiujia...@gmail.com>: > 2017-04-13 20:48 GMT+08:00 Raymond Pierce <ray1110...@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 > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Hello, Steven. Thank you for the advice. New patch in the attachment. Should I post a new message with the patch to ffmpeg-devel@ffmpeg.org list?
From e780cfa4330ae87cd4506ec2ccfe39ea045f2134 Mon Sep 17 00:00:00 2001 From: Ray Pierce <ray1110...@yandex.com> Date: Thu, 13 Apr 2017 20:41:59 +0500 Subject: [PATCH] Add FFplay progress bar feature Signed-off-by: Ray Pierce <ray1110...@yandex.com> --- ffplay.c | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/ffplay.c b/ffplay.c index cf138dc515..a73699475b 100644 --- a/ffplay.c +++ b/ffplay.c @@ -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 *is, double pts, int64_t pos, int serial 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_stream) 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, const char *arg) "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" -- 2.12.2
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel