Commit 6ec5618a authored by Antoine Cellerier's avatar Antoine Cellerier

add --snapshot-prefix and --snapshot-sequential options. --snapshot-prefix...

add --snapshot-prefix and --snapshot-sequential options. --snapshot-prefix lets you choose the filename's prefix (default it "vlcsnap-"). --snapshot-sequential numbers the snapshot starting with 1 and incrementing every time.
parent 51c68fc7
...@@ -308,10 +308,14 @@ static char *ppsz_align_descriptions[] = ...@@ -308,10 +308,14 @@ static char *ppsz_align_descriptions[] =
"picture quality, for instance deinterlacing, or distort" \ "picture quality, for instance deinterlacing, or distort" \
"the video.") "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_( \ #define SNAP_PATH_LONGTEXT N_( \
"Directory where the video snapshots will be stored.") "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_TEXT N_("Video snapshot format")
#define SNAP_FORMAT_LONGTEXT N_( \ #define SNAP_FORMAT_LONGTEXT N_( \
"Image format which will be used to store the video snapshots" ) "Image format which will be used to store the video snapshots" )
...@@ -320,6 +324,10 @@ static char *ppsz_align_descriptions[] = ...@@ -320,6 +324,10 @@ static char *ppsz_align_descriptions[] =
#define SNAP_PREVIEW_LONGTEXT N_( \ #define SNAP_PREVIEW_LONGTEXT N_( \
"Display the snapshot preview in the screen's top-left corner.") "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_TEXT N_("Video cropping")
#define CROP_LONGTEXT N_( \ #define CROP_LONGTEXT N_( \
"This forces the cropping of the source video. " \ "This forces the cropping of the source video. " \
...@@ -1255,11 +1263,15 @@ vlc_module_begin(); ...@@ -1255,11 +1263,15 @@ vlc_module_begin();
set_section( N_("Snapshot") , NULL ); set_section( N_("Snapshot") , NULL );
add_directory( "snapshot-path", NULL, NULL, SNAP_PATH_TEXT, add_directory( "snapshot-path", NULL, NULL, SNAP_PATH_TEXT,
SNAP_PATH_LONGTEXT, VLC_FALSE ); 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, add_string( "snapshot-format", "png", NULL, SNAP_FORMAT_TEXT,
SNAP_FORMAT_LONGTEXT, VLC_FALSE ); SNAP_FORMAT_LONGTEXT, VLC_FALSE );
change_string_list( ppsz_snap_formats, NULL, 0 ); change_string_list( ppsz_snap_formats, NULL, 0 );
add_bool( "snapshot-preview", VLC_TRUE, NULL, SNAP_PREVIEW_TEXT, add_bool( "snapshot-preview", VLC_TRUE, NULL, SNAP_PREVIEW_TEXT,
SNAP_PREVIEW_LONGTEXT, VLC_FALSE ); 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 ); set_section( N_("Window properties" ), NULL );
add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
......
...@@ -187,8 +187,14 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -187,8 +187,14 @@ void vout_IntfInit( vout_thread_t *p_vout )
/* Create a few object variables we'll need later on */ /* 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-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-format", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_vout, "snapshot-preview", VLC_VAR_BOOL | 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, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "height", 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 ); 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 ) ...@@ -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 ); image_handler_t *p_image = image_HandlerCreate( p_vout );
video_format_t fmt_in = {0}, fmt_out = {0}; video_format_t fmt_in = {0}, fmt_out = {0};
char *psz_filename; char *psz_filename = NULL;
subpicture_t *p_subpic; subpicture_t *p_subpic;
picture_t *p_pif; picture_t *p_pif;
vlc_value_t val, format; vlc_value_t val, format;
...@@ -631,11 +637,31 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -631,11 +637,31 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
if ( path != NULL ) if ( path != NULL )
{ {
char *psz_prefix = var_GetString( p_vout, "snapshot-prefix" );
if( !psz_prefix ) psz_prefix = strdup( "vlcsnap-" );
asprintf( &psz_filename, "%s/vlcsnap-%u.%s", val.psz_string, 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, (unsigned int)(p_pic->date / 100000) & 0xFFFFFF,
format.psz_string ); format.psz_string );
closedir( path ); }
free( psz_prefix );
} }
else // The user specified a full path name (including file name) else // The user specified a full path name (including file name)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment