How to take snapshot using libvlc_video_take_snapshot without opening media player

781 Views Asked by At

I am developing a media player in Qt using libvlc actually I wants to create the thumbnail from the video and I have search all over the internet and found out that i can use libvlc_video_take_snapshot function. Which will take the snapshot of the media but the problem is it opens the player to take the snapshot, I want it to take the snapshot without opening any video player. Here's my code

    inst = libvlc_new (0,vlc_args);

    m = libvlc_media_new_location(inst, "file:///home/vinay/Downloads/sample.webm");
    mp = libvlc_media_player_new_from_media(m);

    libvlc_media_player_play(mp);

When I click a button it will take the snapshot and close the media

void expPlayer::on_pushButton_4_clicked()
{
    //const char *image_path="/home/vinay/Documents/snap.png";
    //int result = libvlc_video_take_snapshot(mp, 0, image_path, 0, 0);

    libvlc_media_player_set_position(mp, VLC_THUMBNAIL_POSITION);
    const char *image_path="/home/vinay/Documents/snap.png";
    int result = libvlc_video_take_snapshot(mp, 0, image_path, 0, 0);

    libvlc_media_player_stop(mp);
}
0

There are 0 best solutions below