]> git.sesse.net Git - vlc/commitdiff
add --snapshot-prefix and --snapshot-sequential options. --snapshot-prefix lets you...
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 22 Jul 2006 15:33:03 +0000 (15:33 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 22 Jul 2006 15:33:03 +0000 (15:33 +0000)
src/libvlc.h
src/video_output/vout_intf.c

index f721099222ec1fc9e64d0579162266a35223908d..a295c3cb542cbb522d2a9c3aa9e7a7972f9af476 100644 (file)
@@ -308,10 +308,14 @@ static char *ppsz_align_descriptions[] =
     "picture quality, for instance deinterlacing, or distort" \
     "the video.")
 
-#define SNAP_PATH_TEXT N_("Video snapshot directory")
+#define SNAP_PATH_TEXT N_("Video snapshot directory (or filename)")
 #define SNAP_PATH_LONGTEXT N_( \
     "Directory where the video snapshots will be stored.")
 
+#define SNAP_PREFIX_TEXT N_("Video snapshot file prefix")
+#define SNAP_PREFIX_LONGTEXT N_( \
+    "Video snapshot file prefix" )
+
 #define SNAP_FORMAT_TEXT N_("Video snapshot format")
 #define SNAP_FORMAT_LONGTEXT N_( \
     "Image format which will be used to store the video snapshots" )
@@ -320,6 +324,10 @@ static char *ppsz_align_descriptions[] =
 #define SNAP_PREVIEW_LONGTEXT N_( \
     "Display the snapshot preview in the screen's top-left corner.")
 
+#define SNAP_SEQUENTIAL_TEXT N_("Use sequential numbers instead of timestamps")
+#define SNAP_SEQUENTIAL_LONGTEXT N_( \
+    "Use sequential numbers instead of timestamps for snapshot numbering")
+
 #define CROP_TEXT N_("Video cropping")
 #define CROP_LONGTEXT N_( \
     "This forces the cropping of the source video. " \
@@ -1255,11 +1263,15 @@ vlc_module_begin();
     set_section( N_("Snapshot") , NULL );
     add_directory( "snapshot-path", NULL, NULL, SNAP_PATH_TEXT,
                    SNAP_PATH_LONGTEXT, VLC_FALSE );
+    add_directory( "snapshot-prefix", "vlcsnap-", NULL, SNAP_PATH_TEXT,
+                   SNAP_PATH_LONGTEXT, VLC_FALSE );
     add_string( "snapshot-format", "png", NULL, SNAP_FORMAT_TEXT,
                    SNAP_FORMAT_LONGTEXT, VLC_FALSE );
         change_string_list( ppsz_snap_formats, NULL, 0 );
     add_bool( "snapshot-preview", VLC_TRUE, NULL, SNAP_PREVIEW_TEXT,
               SNAP_PREVIEW_LONGTEXT, VLC_FALSE );
+    add_bool( "snapshot-sequential", VLC_FALSE, NULL, SNAP_SEQUENTIAL_TEXT,
+              SNAP_SEQUENTIAL_LONGTEXT, VLC_FALSE );
 
     set_section( N_("Window properties" ), NULL );
     add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
index b57dcc3fb97e36f7856a8ac3190a62c9d662b0e6..f7fe56e862000aa8936b5ccb9397ed8c21e1f753 100644 (file)
@@ -187,8 +187,14 @@ void vout_IntfInit( vout_thread_t *p_vout )
 
     /* Create a few object variables we'll need later on */
     var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "snapshot-prefix", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "snapshot-format", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "snapshot-preview", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "snapshot-sequential",
+                VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "snapshot-num", VLC_VAR_INTEGER );
+    var_SetInteger( p_vout, "snapshot-num", 1 );
+
     var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
@@ -434,7 +440,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
 {
     image_handler_t *p_image = image_HandlerCreate( p_vout );
     video_format_t fmt_in = {0}, fmt_out = {0};
-    char *psz_filename;
+    char *psz_filename = NULL;
     subpicture_t *p_subpic;
     picture_t *p_pif;
     vlc_value_t val, format;
@@ -628,20 +634,40 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
      * Did the user specify a directory? If not, path = NULL.
      */
     path = opendir ( (const char *)val.psz_string  );
-    
+
     if ( path != NULL )
     {
-        
-        asprintf( &psz_filename, "%s/vlcsnap-%u.%s", val.psz_string,
-                  (unsigned int)(p_pic->date / 100000) & 0xFFFFFF,
-                  format.psz_string );
+        char *psz_prefix = var_GetString( p_vout, "snapshot-prefix" );
+        if( !psz_prefix ) psz_prefix = strdup( "vlcsnap-" );
+
         closedir( path );
+        if( var_GetBool( p_vout, "snapshot-sequential" ) == VLC_TRUE )
+        {
+            int i_num = var_GetInteger( p_vout, "snapshot-num" );
+            FILE *p_file;
+            do
+            {
+                asprintf( &psz_filename, "%s/%s%d.%s", val.psz_string,
+                          psz_prefix, i_num++, format.psz_string );
+            }
+            while( ( p_file = fopen( psz_filename, "r" ) ) && !fclose( p_file ) );
+            var_SetInteger( p_vout, "snapshot-num", i_num );
+        }
+        else
+        {
+            asprintf( &psz_filename, "%s/%s%u.%s", val.psz_string,
+                      psz_prefix,
+                      (unsigned int)(p_pic->date / 100000) & 0xFFFFFF,
+                      format.psz_string );
+        }
+
+        free( psz_prefix );
     }
     else // The user specified a full path name (including file name)
     {
         asprintf ( &psz_filename, "%s", val.psz_string );
     }
-    
+
     free( val.psz_string );
     free( format.psz_string );