Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Libraries (Windows)
#33
Ill leave it and ask that as your on this thingy....is this your wheel house?


Integrating LibVLC into QB64 for video rendering requires a hybrid approach where LibVLC decodes frames into a shared memory buffer, and QB64 (or your C++ bridge) uploads that buffer as an OpenGL texture.
1. Requirements
VLC SDK: You need the libvlc.dll, libvlccore.dll, and the /plugins folder from the VLC Media Player installation directory.
Include Path: Place the VLC include headers in your QB64 directory or specify the path in your build.
2. The C++ Bridge (video_core.cpp)
This code uses LibVLC's video callbacks (lock, unlock, display) to capture raw frames and upload them to an OpenGL texture.
cpp
#include <vlc/vlc.h>
#include <GL/gl.h>
#include <mutex>
#include <vector>

struct VideoCtx {
    std::mutex mutex;
    std::vector<uint8_t> pixelData;
    GLuint textureId = 0;
    int width, height;
    bool updated = false;
};

VideoCtx vCtx;
libvlc_instance_t* libvlc = nullptr;
libvlc_media_player_t* mp = nullptr;

// LibVLC Callbacks
static void* lock(void* opaque, void** planes) {
    VideoCtx* ctx = (VideoCtx*)opaque;
    ctx->mutex.lock();
    *planes = ctx->pixelData.data();
    return nullptr;
}

static void unlock(void* opaque, void* picture, void* const* planes) {
    VideoCtx* ctx = (VideoCtx*)opaque;
    ctx->updated = true;
    ctx->mutex.unlock();
}

extern "C" {
    void InitVideo(const char* file, int w, int h) {
        vCtx.width = w; vCtx.height = h;
        vCtx.pixelData.resize(w * h * 4); // RGBA

        libvlc = libvlc_new(0, nullptr);
        libvlc_media_t* m = libvlc_media_new_path(libvlc, file);
        mp = libvlc_media_player_new_from_media(m);
        libvlc_media_release(m);

        libvlc_video_set_callbacks(mp, lock, unlock, nullptr, &vCtx);
        libvlc_video_set_format(mp, "RGBA", w, h, w * 4);
        libvlc_media_player_play(mp);
    }

    void RenderVideoFrame() {
        if (!vCtx.textureId) glGenTextures(1, &vCtx.textureId);

        glBindTexture(GL_TEXTURE_2D, vCtx.textureId);
       
        vCtx.mutex.lock();
        if (vCtx.updated) {
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, vCtx.width, vCtx.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, vCtx.pixelData.data());
            vCtx.updated = false;
        }
        vCtx.mutex.unlock();

        // Standard OpenGL 1.1 Quad rendering
        glBegin(GL_QUADS);
            glTexCoord2f(0, 1); glVertex2f(-1, -1);
            glTexCoord2f(1, 1); glVertex2f(1, -1);
            glTexCoord2f(1, 0); glVertex2f(1, 1);
            glTexCoord2f(0, 0); glVertex2f(-1, 1);
        glEnd();
    }

    void StopVideo() {
        if (mp) { libvlc_media_player_stop(mp); libvlc_media_player_release(mp); }
        if (libvlc) libvlc_release(libvlc);
    }
}

THEN if you get it finished and to work, basically every format is supported!

Unseen
Reply


Messages In This Thread
Dynamic Libraries (Windows) - by Petr - 12-08-2025, 06:48 PM
RE: Dynamic Libraries - by Petr - 12-08-2025, 07:12 PM
RE: Dynamic Libraries - by Petr - 12-08-2025, 07:52 PM
RE: Dynamic Libraries - by Jack - 12-08-2025, 08:41 PM
RE: Dynamic Libraries - by Petr - 12-09-2025, 07:21 PM
RE: Dynamic Libraries - by Petr - 12-11-2025, 04:19 PM
RE: Dynamic Libraries - by Petr - 12-12-2025, 10:00 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 05:56 PM
RE: Dynamic Libraries - by 2112 - 12-13-2025, 07:06 PM
RE: Dynamic Libraries - by ahenry3068 - 12-13-2025, 07:47 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 07:41 PM
RE: Dynamic Libraries - by 2112 - 12-13-2025, 08:23 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 08:36 PM
RE: Dynamic Libraries - by Petr - 12-13-2025, 09:03 PM
RE: Dynamic Libraries - by ahenry3068 - 12-13-2025, 11:16 PM
RE: Dynamic Libraries - by Petr - 12-14-2025, 12:15 AM
RE: Dynamic Libraries - by Petr - 12-15-2025, 08:22 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-15-2025, 06:30 PM
RE: Dynamic Libraries (Windows) - by Mad Axeman - 12-19-2025, 02:37 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-18-2025, 07:45 PM
RE: Dynamic Libraries (Windows) - by Steffan-68 - 12-18-2025, 08:31 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-18-2025, 08:55 PM
RE: Dynamic Libraries (Windows) - by Steffan-68 - 12-18-2025, 09:48 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-18-2025, 09:32 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-18-2025, 11:53 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-19-2025, 06:40 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 03:08 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 10:35 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 10:54 PM
RE: Dynamic Libraries (Windows) - by Unseen Machine - 12-19-2025, 11:04 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-19-2025, 11:20 PM
RE: Dynamic Libraries (Windows) - by Pete - 12-19-2025, 11:37 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-20-2025, 10:22 PM
RE: Dynamic Libraries (Windows) - by SMcNeill - 12-20-2025, 11:03 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-21-2025, 05:40 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-22-2025, 08:23 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-23-2025, 09:06 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-24-2025, 09:54 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-25-2025, 10:02 AM
RE: Dynamic Libraries (Windows) - by Petr - 12-26-2025, 11:14 PM
RE: Dynamic Libraries (Windows) - by Petr - 12-27-2025, 01:35 PM
RE: Dynamic Libraries (Windows) - by MasterGy - 12-27-2025, 07:23 PM
RE: Dynamic Libraries (Windows) - by Petr - 01-07-2026, 06:31 PM
RE: Dynamic Libraries (Windows) - by Petr - 01-07-2026, 09:13 PM
RE: Dynamic Libraries (Windows) - by Petr - 02-24-2026, 06:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dynamic Libraries (Linux) Petr 19 1,156 12-29-2025, 09:52 PM
Last Post: Petr

Forum Jump:


Users browsing this thread: 1 Guest(s)