libvlc_video_take_snapshot always saves files in png format

This forum is about all development around libVLC.
tylerdukes
New Cone
New Cone
Posts: 2
Joined: 24 Sep 2021 21:49

libvlc_video_take_snapshot always saves files in png format

Postby tylerdukes » 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:

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);
Then, on click of a QPushButton, the program enters a slot which contains:

Code: Select all

libvlc_video_take_snapshot(this->player, 0, "/Pictures/Dir", this->_pqwVideoPlaybackWidget->height(), this->_pqwVideoPlaybackWidget->width());
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.

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: libvlc_video_take_snapshot always saves files in png format

Postby Rémi Denis-Courmont » 25 Sep 2021 15:45

libvlc_video_take_snapshot() always makes PNG by design, as that is lossless.

I don't know what you mean by Libvlc documentation. As far as I can tell, it says nothing about the format.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

tylerdukes
New Cone
New Cone
Posts: 2
Joined: 24 Sep 2021 21:49

Re: libvlc_video_take_snapshot always saves files in png format

Postby tylerdukes » 26 Sep 2021 07:53

My apologies, I misspoke. What I should have said is that the VLC documentation mentions different format options. I was under the impression that libvlc_video_take_snapshot would receive the format from the instance configuration parameters or use a default format if there were none, and that this wasn't working correctly for some reason, but I see now on the github page in vlc/lib/video.c that it is hard coded to use PNG. Aside from modifying and rebuilding the source code, are there any alternatives for taking a screenshot in JPG format using libvlc?

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: libvlc_video_take_snapshot always saves files in png format

Postby mfkl » 27 Sep 2021 04:22

Aside from modifying and rebuilding the source code, are there any alternatives for taking a screenshot in JPG format using libvlc?
I guess not.

You could try libvlc v4 though which has a new thumbnailer API where you can specify jpg https://github.com/videolan/vlc/blob/a6 ... dia.h#L745
https://mfkl.github.io


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 35 guests