screenshots: add --screenshot-directory option

The plan is to use this to change the screenshot default location in
pseudo-gui mode.
This commit is contained in:
wm4 2015-05-01 19:55:43 +02:00
parent 94a3a76ee3
commit 60958ddf9b
4 changed files with 21 additions and 0 deletions

View File

@ -2656,6 +2656,17 @@ Screenshot
``%%``
Replaced with the ``%`` character itself.
``--screenshot-directory=<path>``
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.

View File

@ -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),

View File

@ -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;

View File

@ -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;