[MPlayer-dev-eng] [PATCH] JPEG video output to multiple subdirectories v2
Attila Kinali
attila at kinali.ch
Mon Aug 9 14:28:31 CEST 2004
On Wed, Aug 04, 2004 at 08:23:27PM +0200, Ivo wrote:
> Index: libvo/vo_jpeg.c
> ===================================================================
> RCS file: /cvsroot/mplayer/main/libvo/vo_jpeg.c,v
> retrieving revision 1.12
> diff -u -r1.12 vo_jpeg.c
> --- libvo/vo_jpeg.c 19 Jul 2004 23:11:06 -0000 1.12
> +++ libvo/vo_jpeg.c 4 Aug 2004 17:38:18 -0000
> @@ -36,13 +45,55 @@
> int jpeg_smooth = 0;
> int jpeg_quality = 75;
> char * jpeg_outdir = ".";
> +char * jpeg_subdirs = NULL;
> +int jpeg_maxfiles=1536;
BTW: where does this odd number come from ?
Any reason not to use something like 1000 or 5000 ?
>
> static int framenum=0;
>
> static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
> {
> - image_height=height;
> - image_width=width;
> + char buf[BUFLENGTH];
> + struct stat stat_p;
> +
> +/* Create outdir. If it already exists, test if it's a writable directory */
> +
> + snprintf (buf, BUFLENGTH, "%s", jpeg_outdir);
> +
> + if (mkdir (buf, 0755)<0) {
> + switch (errno) { /* use switch in case other errors need to be caught and handled in the future */
> + case EEXIST:
> + if ( stat(buf, &stat_p) < 0 ) {
> + perror("This error has occurred:");
Use strerror and pass the string to mp_msg
> + mp_msg(MSGT_VO, MSGL_ERR, "%s: Unable to access %s\n", info.short_name, buf);
> + mp_msg(MSGT_VO, MSGL_ERR, "%s: No output will be written to disk.\n", info.short_name);
Can you put those strings into mp-help ? so they can be translated.
Please also check whether some old msgs could be recycled.
}
> @@ -91,10 +142,72 @@
>
> static uint32_t draw_frame(uint8_t * src[])
> {
> - char buf[256];
> + static uint32_t framecounter=0, subdircounter=0;
> + char buf[BUFLENGTH];
> uint8_t *dst= src[0];
> -
> - snprintf (buf, 256, "%s/%08d.jpg", jpeg_outdir, ++framenum);
> + static char subdirname[BUFLENGTH] = "";
> + static uint8_t jpeg_output_enabled=1;
> + struct stat stat_p;
> +
> +/* The jpeg_output_enabled flag can be used to disable the JPEG output while
> + * the vo_jpeg module is already initialized and running. This may be needed
> + * if, for example, file or directory creation fails along the way.
> + * It defaults to 1, which means output is written. */
Bad idea. If something fatal happends, and i call the inability to
create a directory something fatal, then MPlayer should imediatly
fail and thus exit with an error code. Letting MPlayer run and thus keep
the image of everything being ok is the wrong way (and not user
friendly).
Attila Kinali
More information about the MPlayer-dev-eng
mailing list