From patchwork Thu Apr 13 15:53:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Raymond Pierce X-Patchwork-Id: 3396 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp755162vsd; Thu, 13 Apr 2017 08:54:00 -0700 (PDT) X-Received: by 10.223.161.130 with SMTP id u2mr3496606wru.203.1492098840239; Thu, 13 Apr 2017 08:54:00 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 30si12634181wrq.36.2017.04.13.08.53.59; Thu, 13 Apr 2017 08:54:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@yandex.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4DBA4689890; Thu, 13 Apr 2017 18:53:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from forward3h.cmail.yandex.net (forward3h.cmail.yandex.net [87.250.230.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B5DC689890 for ; Thu, 13 Apr 2017 18:53:44 +0300 (EEST) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward3h.cmail.yandex.net (Yandex) with ESMTP id 8FA2B2105F for ; Thu, 13 Apr 2017 18:53:49 +0300 (MSK) Received: from web50j.yandex.ru (web50j.yandex.ru [5.45.198.200]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id rknmNd0ZHj-rn20NFtG; Thu, 13 Apr 2017 18:53:49 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1492098829; bh=b4d8JQtpsExa1MBcpiQYqhPcIbhKeNt8kZuh7fC1VMg=; h=From:To:In-Reply-To:References:Subject:Message-Id:Date; b=LARUvdKD9uDZ6BSWHM1pqhwbv4hLe60H2SplpF1pa8zQxDjcteC2+a06/4gwvysYW XcqoJVGnrMugR7rWZJsK4fdE8WsF8cY1p+tvyA2CtPZffaoYhXsM/D5SPdP3ggceDs 3QvMW6ZIg1TVvWM8ZzneU7zCYE8nBu2PtQPo4zJ4= Authentication-Results: mxback5j.mail.yandex.net; dkim=pass header.i=@yandex.com Received: by web50j.yandex.ru with HTTP; Thu, 13 Apr 2017 18:53:49 +0300 From: Raymond Pierce To: FFmpeg development discussions and patches In-Reply-To: References: <3952131492087693@web47g.yandex.ru> MIME-Version: 1.0 Message-Id: <97651492098829@web50j.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Thu, 13 Apr 2017 10:53:49 -0500 Subject: Re: [FFmpeg-devel] FFplay: progress bar feature proposal X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 13.04.2017, 09:40, "Steven Liu" : > 2017-04-13 20:48 GMT+08:00 Raymond Pierce : > >>  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 Date: Thu, 13 Apr 2017 20:41:59 +0500 Subject: [PATCH] Add FFplay progress bar feature Signed-off-by: Ray Pierce --- 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