[FFmpeg-devel] [PATCHv2 1/2] ffplay: options to specify window position

Marton Balint cus at passwd.hu
Thu Oct 4 20:44:11 EEST 2018



On Wed, 3 Oct 2018, Dave Rice wrote:

> Thanks Marton for comments. Here is a revision to the first patch.
>
> From 3fe6a9e5279a280af9a06843621737ddc44529cc Mon Sep 17 00:00:00 2001
> From: Dave Rice <dave at dericed.com>
> Date: Mon, 1 Oct 2018 17:07:44 -0400
> Subject: [PATCHv2 1/2] ffplay: options to specify window position
>
> ---
> doc/ffplay.texi  | 4 ++++
> fftools/ffplay.c | 6 +++++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
> index dcb86ce13c..a3da2cd570 100644
> --- a/doc/ffplay.texi
> +++ b/doc/ffplay.texi
> @@ -74,6 +74,10 @@ as 100.
> Force format.
> @item -window_title @var{title}
> Set window title (default is the input filename).
> + at item -screen_left @var{title}
> +Set the x position for the left of the window (default is a centered window).
> + at item -screen_top @var{title}
> +Set the y position for the top of the window (default is a centered window).

Based on the code below, the options should be -left and -top.

> @item -loop @var{number}
> Loops movie playback <number> times. 0 means forever.
> @item -showmode @var{mode}
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index e375a32ec2..6cc59b4d33 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -314,6 +314,8 @@ static int default_width  = 640;
> static int default_height = 480;
> static int screen_width  = 0;
> static int screen_height = 0;
> +static int left = SDL_WINDOWPOS_CENTERED;
> +static int top = SDL_WINDOWPOS_CENTERED;

You should call the variables screen_left and screen_top because 
screen_width and screen_height is used for window width/height.

> static int audio_disable;
> static int video_disable;
> static int subtitle_disable;
> @@ -1346,7 +1348,7 @@ static int video_open(VideoState *is)
>     SDL_SetWindowTitle(window, window_title);
>
>     SDL_SetWindowSize(window, w, h);
> -    SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
> +    SDL_SetWindowPosition(window, left, top);
>     if (is_full_screen)
>         SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
>     SDL_ShowWindow(window);
> @@ -3602,6 +3604,8 @@ static const OptionDef options[] = {
>     { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" },
>     { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" },
>     { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" },
> +    { "left", OPT_INT | HAS_ARG | OPT_EXPERT, { &left }, "set the x position for the left of the window", "x pos" },
> +    { "top", OPT_INT | HAS_ARG | OPT_EXPERT, { &top }, "set the y position for the top of the window", "y pos" },
> #if CONFIG_AVFILTER
>     { "vf", OPT_EXPERT | HAS_ARG, { .func_arg = opt_add_vfilter }, "set video filters", "filter_graph" },
>     { "af", OPT_STRING | HAS_ARG, { &afilters }, "set audio filters", "filter_graph" },
> --

Regards,
Marton


More information about the ffmpeg-devel mailing list