Search code examples
c++libvlc

How to take snapshot in libVLC without showing the Media Player


I am trying to take snapshot from VLC player using libVLC. But whenever I run the following code, a window opens showing the video streaming and I don't want to open the media player window while doing that. I am taking the video input from an IP camera using RTSP link. Is there a way where I can achieve my goal by keeping the media player window hidden?

Here is my code that I've done till now.

    m = libvlc_media_new_location(inst, "IP/camera/rtsp/link");
    mp = libvlc_media_player_new_from_media(m);
    libvlc_media_player_play(mp);
    while (1) {
        Sleep(500);
        const char* image_path = "E:\\frames\\image.jpg";
        int result = libvlc_video_take_snapshot(mp, 0, image_path, 0, 0);
    }

    libvlc_media_player_stop(mp);
    libvlc_media_player_release(mp);
    libvlc_release(inst);

Solution

  • Thank for your question. Add

     const char* const vlc_args[] = {
                "--intf", "dummy",                 
               "--vout", "dummy",                 
    
        };
    

    when creating libvlc new inst and pass it as argument.