Search code examples
c++video-streaminglibvlc

C++ LibVLC Create Stream from Frames/Images


I want to use LibVLC for creating a Video from Images. As for now I have no experience with LibVLC.

I already Implemented a test Project like here (A simple C program to play mp3 using libvlc).

Is there any Way to create an Instance of "libvlc_media_t" and put images to it instead of calling "libvlc_media_new_path" to load a Video from a File? Or are there any other Possibilities?


Solution

  • Create a media list and media play list in addition to a media player:

    media_list_ = libvlc_media_list_new(vlc_instance_);
    media_list_player_ = libvlc_media_list_player_new(vlc_instance_);
    libvlc_media_list_player_set_media_list(media_list_player_, media_list_);
    libvlc_media_list_player_set_media_player(media_list_player_, media_player_);
    

    You can add image files to a vlc play list in the same way as you can add a video.

    libvlc_media_t* media = libvlc_media_new_path(vlc_instance_, "image file");
    
    if (media) {
          libvlc_media_list_lock(media_list_);
          libvlc_media_list_add_media(media_list_, media)
          libvlc_media_list_unlock(media_list_);
    }
    

    You can then cycle through the images by using the following:

    libvlc_media_list_player_play_item_at_index(media_list_player_, index)