comparison libvo/vo_png.c @ 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 8fa2f43cb760
children ddb45e9443ec
comparison
equal deleted inserted replaced
32754:08deb5816d9c 32755:f03a237a8d26
52 52
53 const LIBVO_EXTERN (png) 53 const LIBVO_EXTERN (png)
54 54
55 static int z_compression; 55 static int z_compression;
56 static char *png_outdir; 56 static char *png_outdir;
57 static char *png_outfile_prefix;
57 static int framenum; 58 static int framenum;
58 static int use_alpha; 59 static int use_alpha;
59 static AVCodecContext *avctx; 60 static AVCodecContext *avctx;
60 static uint8_t *outbuffer; 61 static uint8_t *outbuffer;
61 int outbuffer_size; 62 int outbuffer_size;
133 FILE *outfile; 134 FILE *outfile;
134 135
135 // if -dr or -slices then do nothing: 136 // if -dr or -slices then do nothing:
136 if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE; 137 if(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK)) return VO_TRUE;
137 138
138 snprintf (buf, 100, "%s/%08d.png", png_outdir, ++framenum); 139 snprintf (buf, 100, "%s/%s%08d.png", png_outdir, png_outfile_prefix, ++framenum);
139 outfile = fopen(buf, "wb"); 140 outfile = fopen(buf, "wb");
140 if (!outfile) { 141 if (!outfile) {
141 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno)); 142 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorOpeningForWriting, strerror(errno));
142 return 1; 143 return 1;
143 } 144 }
199 av_freep(&avctx); 200 av_freep(&avctx);
200 av_freep(&outbuffer); 201 av_freep(&outbuffer);
201 outbuffer_size = 0; 202 outbuffer_size = 0;
202 free(png_outdir); 203 free(png_outdir);
203 png_outdir = NULL; 204 png_outdir = NULL;
205 free(png_outfile_prefix);
206 png_outfile_prefix = NULL;
204 } 207 }
205 208
206 static void check_events(void){} 209 static void check_events(void){}
207 210
208 static int int_zero_to_nine(void *value) 211 static int int_zero_to_nine(void *value)
213 216
214 static const opt_t subopts[] = { 217 static const opt_t subopts[] = {
215 {"alpha", OPT_ARG_BOOL, &use_alpha, NULL}, 218 {"alpha", OPT_ARG_BOOL, &use_alpha, NULL},
216 {"z", OPT_ARG_INT, &z_compression, int_zero_to_nine}, 219 {"z", OPT_ARG_INT, &z_compression, int_zero_to_nine},
217 {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL}, 220 {"outdir", OPT_ARG_MSTRZ, &png_outdir, NULL},
221 {"prefix", OPT_ARG_MSTRZ, &png_outfile_prefix, NULL },
218 {NULL} 222 {NULL}
219 }; 223 };
220 224
221 static int preinit(const char *arg) 225 static int preinit(const char *arg)
222 { 226 {
223 z_compression = 0; 227 z_compression = 0;
224 png_outdir = strdup("."); 228 png_outdir = strdup(".");
229 png_outfile_prefix = strdup("");
225 use_alpha = 0; 230 use_alpha = 0;
226 if (subopt_parse(arg, subopts) != 0) { 231 if (subopt_parse(arg, subopts) != 0) {
227 return -1; 232 return -1;
228 } 233 }
229 avcodec_register_all(); 234 avcodec_register_all();