changeset 36752:af146b0d33f0

Allow specifying custom path and name for screenshot files.
author reimar
date Sun, 16 Feb 2014 14:01:23 +0000
parents ca939d7e25be
children b3afe52119c4
files DOCS/man/en/mplayer.1 libmpcodecs/vf_screenshot.c
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Sun Feb 16 14:01:21 2014 +0000
+++ b/DOCS/man/en/mplayer.1	Sun Feb 16 14:01:23 2014 +0000
@@ -7938,13 +7938,16 @@
 .RE
 .
 .TP
-.B screenshot
+.B screenshot=prefix
 Allows acquiring screenshots of the movie using slave mode
 commands that can be bound to keypresses.
 See the slave mode documentation and the INTERACTIVE CONTROL
 section for details.
-Files named 'shotNNNN.png' will be saved in the working directory,
+By default files named 'shotNNNN.png' will be saved in the working directory,
 using the first available number \- no files will be overwritten.
+Specify a prefix to change the name or location, e.g.
+\-vf screenshot=shots/now will save the files in the directory
+shots with nowNNNN.png as name.
 The filter has no overhead when not used and accepts an arbitrary
 colorspace, so it is safe to add it to the configuration file.
 Make sure that the screenshot filter is added after all other filters
--- a/libmpcodecs/vf_screenshot.c	Sun Feb 16 14:01:21 2014 +0000
+++ b/libmpcodecs/vf_screenshot.c	Sun Feb 16 14:01:23 2014 +0000
@@ -43,7 +43,8 @@
 
 struct vf_priv_s {
     int frameno;
-    char fname[102];
+    char fname[PATH_MAX];
+    char *prefix;
     /// shot stores current screenshot mode:
     /// 0: don't take screenshots
     /// 1: take single screenshot, reset to 0 afterwards
@@ -130,7 +131,7 @@
 static void gen_fname(struct vf_priv_s* priv)
 {
     do {
-        snprintf(priv->fname, sizeof(priv->fname), "shot%04d.png", ++priv->frameno);
+        snprintf(priv->fname, sizeof(priv->fname), "%s%04d.png", priv->prefix, ++priv->frameno);
     } while (fexists(priv->fname) && priv->frameno < 100000);
     if (fexists(priv->fname)) {
         priv->fname[0] = '\0';
@@ -282,6 +283,7 @@
     if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
     av_free(vf->priv->buffer);
     free(vf->priv->outbuffer);
+    free(vf->priv->prefix);
     free(vf->priv);
 }
 
@@ -296,6 +298,7 @@
     vf->get_image=get_image;
     vf->uninit=uninit;
     vf->priv=malloc(sizeof(struct vf_priv_s));
+    vf->priv->prefix = strdup(args ? args : "shot");
     vf->priv->frameno=0;
     vf->priv->shot=0;
     vf->priv->store_slices=0;