Important: Please read the Qt Code of Conduct -

How to take snapshot using libvlc_video_take_snapshot without opening media player

  • 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);

    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);

  • Lifetime Qt Champion

    Wouldn't it be better to as the vlc devs on how to do so? I don't see where Qt can help you / can do anything against this behavior of libvlc...

Log in to reply