summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/mplayer.122
-rw-r--r--cfg-mplayer.h4
-rw-r--r--help/help_mp-en.h15
-rw-r--r--libvo/vo_jpeg.c111
4 files changed, 140 insertions, 12 deletions
diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index f921db882d..34609eaf16 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -1924,17 +1924,27 @@ Available options are:
.PD 0
.RSs
.IPs [no]progressive
-Specify standard or progressive JPEG.
+Specify standard or progressive JPEG (default: noprogressive).
.IPs [no]baseline
-Specify use of baseline or not.
+Specify use of baseline or not (default: baseline).
.IPs optimize=<0\-100>
-optimization factor
+optimization factor (default: 100)
.IPs smooth=<0\-100>
-smooth factor
+smooth factor (default: 0)
.IPs quality=<0\-100>
-quality factor
+quality factor (default: 75)
.IPs outdir=<value>
-directory to save the JPEG files
+Specify the directory to save the JPEG files to.
+If not specified, all JPEG files are written to the current directory.
+.IPs subdirs=<value>
+If specified, MPlayer will create numbered subdirectories with the
+specified prefix.
+If it's not specified, no subdirectories are created
+and all JPEG files are written to the same directory.
+.IPs maxfiles=<value>
+Maximum number of JPEG files to be saved per subdirectory in case subdirs
+is specified.
+Must be equal to or larger than 1 (default: 1000).
.RE
.PD 1
.
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 05ac9f98d4..0536f592f8 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -36,6 +36,8 @@ extern int jpeg_optimize;
extern int jpeg_smooth;
extern int jpeg_quality;
extern char * jpeg_outdir;
+extern char * jpeg_subdirs;
+extern int jpeg_maxfiles;
#endif
#ifdef HAVE_SDL
//extern char *sdl_driver;
@@ -152,6 +154,8 @@ m_option_t jpeg_conf[]={
{"smooth", &jpeg_smooth, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
{"quality", &jpeg_quality, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
{"outdir", &jpeg_outdir, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"subdirs", &jpeg_subdirs, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"maxfiles", &jpeg_maxfiles, CONF_TYPE_INT, CONF_MIN, 1, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
};
#endif
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index 7df4c0ae44..ccc563e68a 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -86,7 +86,6 @@ static char help_text[]=
#define MSGTR_CouldntInitAudioCodec "Could not initialize audio codec -> no sound.\n"
#define MSGTR_TryForceVideoFmtStr "Trying to force video codec driver family %s...\n"
#define MSGTR_CantFindVideoCodec "Cannot find codec matching selected -vo and video format 0x%X.\n"
-#define MSGTR_VOincompCodec "The selected video_out device is incompatible with this codec.\n"
#define MSGTR_CannotInitVO "FATAL: Cannot initialize video driver.\n"
#define MSGTR_CannotInitAO "Could not open/initialize audio device -> no sound.\n"
#define MSGTR_StartPlaying "Starting playback...\n"
@@ -746,3 +745,17 @@ static char help_text[]=
#define MSGTR_MSGBOX_LABEL_Warning "Warning!"
#endif
+
+// ======================= VO Video Output drivers ========================
+
+#define MSGTR_VOincompCodec "The selected video_out device is incompatible with this codec.\n"
+
+// vo_jpeg.c
+#define MSGTR_VO_JPEG_GenericError "This error has occurred"
+#define MSGTR_VO_JPEG_UnableToAccess "Unable to access"
+#define MSGTR_VO_JPEG_ExistsButNoDirectory "already exists, but is not a directory."
+#define MSGTR_VO_JPEG_DirExistsButNotWritable "Output directory already exists, but is not writable."
+#define MSGTR_VO_JPEG_DirExistsAndIsWritable "Output directory already exists and is writable."
+#define MSGTR_VO_JPEG_CantCreateDirectory "Unable to create ouput directory."
+#define MSGTR_VO_JPEG_DirectoryCreateSuccess "Output directory successfully created."
+
diff --git a/libvo/vo_jpeg.c b/libvo/vo_jpeg.c
index 968db92eb4..0fa767d6c8 100644
--- a/libvo/vo_jpeg.c
+++ b/libvo/vo_jpeg.c
@@ -3,6 +3,7 @@
*
* Copyright 2002 by Pontscho (pontscho@makacs.poliod.hu)
* 25/04/2003: Spring cleanup -- alex
+ * 04/08/2004: Added multiple subdirectory support -- ivop@euronet.nl
*
*/
@@ -14,8 +15,18 @@
#include <jpeglib.h>
#include "config.h"
+#include "mp_msg.h"
#include "video_out.h"
#include "video_out_internal.h"
+#include "mplayer.h" /* for exit_player() */
+#include "help_mp.h"
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Used for temporary buffers to store file- and pathnames */
+#define BUFLENGTH 512
static vo_info_t info=
{
@@ -36,13 +47,51 @@ int jpeg_optimize = 100;
int jpeg_smooth = 0;
int jpeg_quality = 75;
char * jpeg_outdir = ".";
+char * jpeg_subdirs = NULL;
+int jpeg_maxfiles=1000;
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 ) {
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_JPEG_GenericError, strerror(errno) );
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_JPEG_UnableToAccess,buf);
+ exit_player(MSGTR_Exit_error);
+ }
+ if ( !S_ISDIR(stat_p.st_mode) ) {
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, buf, MSGTR_VO_JPEG_ExistsButNoDirectory);
+ exit_player(MSGTR_Exit_error);
+ }
+ if ( !(stat_p.st_mode & S_IWUSR) ) {
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, MSGTR_VO_JPEG_DirExistsButNotWritable);
+ exit_player(MSGTR_Exit_error);
+ }
+
+ mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, MSGTR_VO_JPEG_DirExistsAndIsWritable);
+ break;
+
+ default:
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_JPEG_GenericError, strerror(errno) );
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s\n", info.short_name, MSGTR_VO_JPEG_CantCreateDirectory);
+ exit_player(MSGTR_Exit_error);
+ } /* end switch */
+ } else {
+ mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, MSGTR_VO_JPEG_DirectoryCreateSuccess);
+ } /* end if */
+
+ image_height=height;
+ image_width=width;
return 0;
}
@@ -91,10 +140,59 @@ static uint32_t jpeg_write( uint8_t * name,uint8_t * buffer )
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] = "";
+ struct stat stat_p;
+
+/* Start writing to new subdirectory after a certain amount of frames */
+ if ( framecounter == jpeg_maxfiles ) {
+ framecounter = 0;
+ }
+
+/* If framecounter is zero (or reset to zero), increment subdirectory number
+ * and create the subdirectory.
+ * If jpeg_subdirs is not set, do nothing and resort to old behaviour. */
+ if ( !framecounter && jpeg_subdirs ) {
+ snprintf (subdirname, BUFLENGTH, "%s%08d", jpeg_subdirs, ++subdircounter);
+ snprintf (buf, BUFLENGTH, "%s/%s", jpeg_outdir, subdirname);
+ 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 ) {
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_JPEG_GenericError, strerror(errno) );
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s %s\n", info.short_name, MSGTR_VO_JPEG_UnableToAccess, buf);
+ exit_player(MSGTR_Exit_error);
+ }
+ if ( !S_ISDIR(stat_p.st_mode) ) {
+ mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s %s\n", info.short_name, buf, MSGTR_VO_JPEG_ExistsButNoDirectory);
+ exit_player(MSGTR_Exit_error);
+ }
+ if ( !(stat_p.st_mode & S_IWUSR) ) {
+ mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s - %s\n", info.short_name, buf, MSGTR_VO_JPEG_DirExistsButNotWritable);
+ exit_player(MSGTR_Exit_error);
+ }
+
+ mp_msg(MSGT_VO, MSGL_INFO, "\n%s: %s - %s\n", info.short_name, buf, MSGTR_VO_JPEG_DirExistsAndIsWritable);
+ break;
+
+ default:
+ mp_msg(MSGT_VO, MSGL_ERR, "%s: %s: %s\n", info.short_name, MSGTR_VO_JPEG_GenericError, strerror(errno) );
+ mp_msg(MSGT_VO, MSGL_ERR, "\n%s: %s - %s.\n", info.short_name, buf, MSGTR_VO_JPEG_CantCreateDirectory);
+ exit_player(MSGTR_Exit_error);
+ break;
+ }
+ } /* switch */
+ } /* if !framecounter && jpeg_subdirs */
+
+
+ framenum++;
+
+/* snprintf the full pathname of the outputfile */
+ snprintf (buf, BUFLENGTH, "%s/%s/%08d.jpg", jpeg_outdir, subdirname, framenum);
+
+ framecounter++;
return jpeg_write( buf,src[0] );
}
@@ -142,3 +240,6 @@ static uint32_t control(uint32_t request, void *data, ...)
}
return VO_NOTIMPL;
}
+
+#undef BUFLENGTH
+