From 60958ddf9b1db1101f81c3db59b8e8c980af7cf2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 1 May 2015 19:55:43 +0200 Subject: screenshots: add --screenshot-directory option The plan is to use this to change the screenshot default location in pseudo-gui mode. --- DOCS/man/options.rst | 11 +++++++++++ options/options.c | 1 + options/options.h | 1 + player/screenshot.c | 8 ++++++++ 4 files changed, 21 insertions(+) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 5e2a0bc8e0..b46f5992e6 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2656,6 +2656,17 @@ Screenshot ``%%`` Replaced with the ``%`` character itself. +``--screenshot-directory=`` + Store screenshots in this directory. This path is joined with the filename + generated by ``--screenshot-template``. If the template filename is already + absolute, the directory is ignored. + + If the directory does not exist or is not a directory, an error is + generated. + + This option is not set by default, and thus will write screenshots to the + directory from which mpv was started. + ``--screenshot-jpeg-quality=<0-100>`` Set the JPEG quality level. Higher means better quality. The default is 90. diff --git a/options/options.c b/options/options.c index f59f1356c0..5965ae1692 100644 --- a/options/options.c +++ b/options/options.c @@ -543,6 +543,7 @@ const m_option_t mp_opts[] = { OPT_SUBSTRUCT("screenshot", screenshot_image_opts, image_writer_conf, 0), OPT_STRING("screenshot-template", screenshot_template, 0), + OPT_STRING("screenshot-directory", screenshot_direcrory, 0), OPT_SUBSTRUCT("input", input_opts, input_config, 0), diff --git a/options/options.h b/options/options.h index ced518453f..c3b4831fa6 100644 --- a/options/options.h +++ b/options/options.h @@ -206,6 +206,7 @@ typedef struct MPOpts { struct image_writer_opts *screenshot_image_opts; char *screenshot_template; + char *screenshot_direcrory; double force_fps; int index_mode; diff --git a/player/screenshot.c b/player/screenshot.c index a47de292d5..1db1d95996 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -280,6 +280,14 @@ static char *gen_fname(screenshot_ctx *ctx, const char *file_ext) return NULL; } + char *dir = ctx->mpctx->opts->screenshot_direcrory; + if (dir && dir[0]) { + void *t = fname; + dir = mp_get_user_path(t, ctx->mpctx->global, dir); + fname = mp_path_join(NULL, bstr0(dir), bstr0(fname)); + talloc_free(t); + } + if (!mp_path_exists(fname)) return fname; -- cgit v1.2.3