libvlc_video_take_snapshot always saves files in png format
Posted: 24 Sep 2021 22:39
Hello all. I am developing an application on RHEL8 using vlc 3.0.13.1 and Qt 5.12.5 which incorporates an instance of VLC embedded in a QWidget and allows the user to take a screenshot of the vlc player. The libvlc documentation mentions that the screenshot can be saved in png, jpg, or tiff format, but the libvlc_video_take_snapshot function always saves the image as a png, even if the "--snapshot-format=jpg" argument is added to the configuration arguments used to initialize the vlc instance. In the maximum verbosity build dialogue, there is no mention whatsoever of the snapshot format and when the snapshot is executed, it just casually loads and removes the png module as if nothing has gone awry. I have tried this with an assortment of configuration arguments thinking there may be some conflict, but consistently, the only one which is seemingly ignored is "--snapshot-format=fmt"
Basically, the vlc part of my program looks like:
Then, on click of a QPushButton, the program enters a slot which contains:
and the screenshot is saved as "file.png".
Interestingly, if I open a command line and run:
"vlc path/to/file.avi --verbose=2 --snapshot-format=jpg" and then use Shift+S to take a screenshot, the resulting file is saved as a jpg, as expected.
I have tried using "jpeg" in my config args (made no difference), as well as specifying the full filename with the .jpg extension as the third parameter of the libvlc_video_take_snapshot function. Doing that does yield a jpg file, at least in name. It is still encoded with the png module, however, and thus cannot be opened.
I have also tried using VLC 3.0.16.1 on another machine with the same version of RHEL8 and Qt 5, with the same results. I have exhausted all existing ideas for now, so I say thank you in advance for any help offered, and wish you all a happy weekend.
Basically, the vlc part of my program looks like:
Code: Select all
const char * const vlc_args[] =
{
“--verbosity=2”,
“--arg-1”,
“--arg-2”,
“--snapshot-format=jpg”,
“--arg-x”
};
this->instance = libvlc_new(sizeof(vlc_args) / (sizeof(vlc_args[0]), vlc_args);
const char * const media_loc[] = {"path/to/file.avi"};
this->media = libvlc_media_new_path(this->instance, media_loc[0]);
int id = this->_pqwVideoPlaybackWidget->winId(); //QWidget which hosts the vlc player
this->player = libvlc_media_player_new(this->instance);
libvlc_media_player_set_media(this->player, this->media);
libvlc_media_player_set_xwindow(this->player, id)
libvlc_media_player_play(this->player);
Code: Select all
libvlc_video_take_snapshot(this->player, 0, "/Pictures/Dir", this->_pqwVideoPlaybackWidget->height(), this->_pqwVideoPlaybackWidget->width());
Interestingly, if I open a command line and run:
"vlc path/to/file.avi --verbose=2 --snapshot-format=jpg" and then use Shift+S to take a screenshot, the resulting file is saved as a jpg, as expected.
I have tried using "jpeg" in my config args (made no difference), as well as specifying the full filename with the .jpg extension as the third parameter of the libvlc_video_take_snapshot function. Doing that does yield a jpg file, at least in name. It is still encoded with the png module, however, and thus cannot be opened.
I have also tried using VLC 3.0.16.1 on another machine with the same version of RHEL8 and Qt 5, with the same results. I have exhausted all existing ideas for now, so I say thank you in advance for any help offered, and wish you all a happy weekend.