VLCMediaPlayer.saveVideoSnapshotAt method always saves snapshots in PNG format
Hi!
I know what follows is not an important issue, but I have been asked by a couple Users to save snapshots as JPEGs instead of PNGs, in order to save disk space. So, I've been investigating the options the saveVideoSnapshotAt
method, which I am currently using, offers and I don't seem to be able to have the media player save the snapshot as JPEG.
Passing --snapshot-format=jpg
as option when initialising the media player seems to be ignored, as the saved snapshot still is in PNG format (and size).
I took a quick look at the libvlc_video_take_snapshot
method in video.c:
int
libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num,
const char *psz_filepath,
unsigned int i_width, unsigned int i_height )
{
assert( psz_filepath );
vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
return -1;
/* FIXME: This is not atomic. All parameters should be passed at once
* (obviously _not_ with var_*()). Also, the libvlc object should not be
* used for the callbacks: that breaks badly if there are concurrent
* media players in the instance. */
var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-width", i_width);
var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER );
var_SetInteger( p_vout, "snapshot-height", i_height );
var_Create( p_vout, "snapshot-path", VLC_VAR_STRING );
var_SetString( p_vout, "snapshot-path", psz_filepath );
var_Create( p_vout, "snapshot-format", VLC_VAR_STRING );
var_SetString( p_vout, "snapshot-format", "png" );
var_TriggerCallback( p_vout, "video-snapshot" );
vout_Release(p_vout);
return 0;
}
and I can't help but notice that the snapshot-format seems to be hardcoded instead of a parameter (var_SetString( p_vout, "snapshot-format", "png" );
), but honestly I'm out of my depth looking at the VLC source code in C and I might have this all wrong.
I then thought of saving the snapshot to disk in PNG and then use the lastSnapshot
property of the media player to access the NSImage and save that as JPEG, but lastSnapshot seem to be "delayed" (meaning that the first time that I save a snapshot, that property is still nil, and instead is not when I save additional snapshots) and this wasn't a great approach in the first place (save a PNG just to have lastSnapshot contain the NSImage to be saved in JPEG, and then delete the PNG).
Sure, I could save the PNG as I'm already doing, then read it back from disk and save a JPEG before deleting the PNG, but ugh... just like in the previous approach, doesn't seem a great way to do things.
Is it possible to have the --snapshot-format=jpg
option to be honoured in a future release?
Thank you in advance!