diff libmpcodecs/vf_screenshot.c @ 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
line wrap: on
line diff
--- 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;