changeset 32755:f03a237a8d26

Add prefix filename option for PNG video output. Patch by Marco Aurlio Graciotto Silva, magsilva gmail.
author cboesch
date Wed, 02 Feb 2011 23:55:16 +0000
parents 08deb5816d9c
children 1c12696d7af6
files DOCS/man/en/mplayer.1 libvo/vo_png.c
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Wed Feb 02 18:30:20 2011 +0000
+++ b/DOCS/man/en/mplayer.1	Wed Feb 02 23:55:16 2011 +0000
@@ -4592,6 +4592,8 @@
 0 is no compression, 9 is maximum compression.
 .IPs outdir=<dirname>
 Specify the directory to save the PNG files to (default: ./).
+.IPs prefix=<prefix>
+Specify the prefix to be used for the PNG filenames (default: no prefix).
 .IPs alpha (default: noalpha)
 Create PNG files with an alpha channel.
 Note that MPlayer in general does not support alpha, so this will only
--- a/libvo/vo_png.c	Wed Feb 02 18:30:20 2011 +0000
+++ b/libvo/vo_png.c	Wed Feb 02 23:55:16 2011 +0000
@@ -54,6 +54,7 @@
 
 static int z_compression;
 static char *png_outdir;
+static char *png_outfile_prefix;
 static int framenum;
 static int use_alpha;
 static AVCodecContext *avctx;
@@ -135,7 +136,7 @@
     // if -dr or -slices then do nothing:
     if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
 
-    snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum);
+    snprintf (buf, 100, "%s/%s%08d.png", png_outdir, png_outfile_prefix, ++framenum);
     outfile = fopen(buf, "wb");
     if (!outfile) {
         mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno));
@@ -201,6 +202,8 @@
     outbuffer_size = 0;
     free(png_outdir);
     png_outdir = NULL;
+    free(png_outfile_prefix);
+    png_outfile_prefix = NULL;
 }
 
 static void check_events(void){}
@@ -215,6 +218,7 @@
     {"alpha", OPT_ARG_BOOL, &use_alpha, NULL},
     {"z",   OPT_ARG_INT, &z_compression, int_zero_to_nine},
     {"outdir",      OPT_ARG_MSTRZ,  &png_outdir,           NULL},
+    {"prefix", OPT_ARG_MSTRZ, &png_outfile_prefix, NULL },
     {NULL}
 };
 
@@ -222,6 +226,7 @@
 {
     z_compression = 0;
     png_outdir = strdup(".");
+    png_outfile_prefix = strdup("");
     use_alpha = 0;
     if (subopt_parse(arg, subopts) != 0) {
         return -1;