Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Libraries (Windows)
#31
(12-19-2025, 10:35 PM)Petr Wrote: This is a video player written in C++. Attached are the 32-bit and 64-bit DLLs, the source code,  BAS program and all the files needed for compilation. The only bug in the program is that it cannot be run in fullscreen mode, because the video window then hides behind the QB64PE screen. I will be porting this program to Linux in the near future as well - I finally finished installing Linux yesterday to laptop with everything that’s needed.

The program includes options to fast-forward and rewind, play at reduced, normal, or increased speeds, control the volume, and pause/resume the video. Of course, you can position it anywhere on the screen (with adjustable width and height for the video playback). There is also an option to zoom the video in or out using the + and - buttons.
Windows reports a virus!!!!
Reply
#32
Yes. Unseen Machine. Those are the compiled DLLs. But if you think it's a virus, don't download it. Windows reports all sorts of nonsense. On the other hand, you can run it through an alternative antivirus. And that's also why there are included all source files. Don't trust those DLLs? Well, compile it yourself.


Reply
#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
#34
I'll see what I can do about it, thanks for the suggestions. I'll look into it.


Reply
#35
Can't get the aaa_dop.avi to play in code from post 14, either. I am compiling on QB64 4.0, not 4.2. Maybe that's the problem, but it accepts the code and compiles it in 4.0 just fine. It just hangs when starting, and then crashes.

My avi and yours both ply on my VLC and SMPlayer.

Your avi will play SOUND only in the version on post 10. Maybe the smaller size makes it so the sound plays to completion, where on my much larger file it just plays a couple seconds and loops.

Tricky stuff. Hard to get it working across all systems and couple that trying to get a system that supports so many vid formats, mp4 (the one I most use) mov (Apple) mpeg, mpg, asf, wmv, flv, rm, and probably a few others.

Well I'm glad it works on your system and I hope you find several uses for it. Fun stuff, thanks for sharing. +1

Pete Smile
Reply
#36
[Project Release] VLC-powered Media Player for QB64PE (Native Graphics & _SndRaw Sync)


Hi everyone,
I’m excited to announce the completion of a media player project for QB64PE that leverages the power of libVLC. This project utilizes the VLC libraries along with two custom-built bridge libraries that facilitate communication between the QB64PE environment and the VLC backend.
Key Technical Features:
  • Native Integration: Unlike many implementations that simply "overlay" a window on top of the IDE, this player renders video directly onto the QB64PE graphic screenAudio Handling: For audio output, I’m using_SndRaw Getting this to work was quite a challenge, but it allows for much tighter control within the QB64 environment.A/V Sync: I have implemented a synchronization logic that handles the timing between the video frames and the raw audio stream as efficiently as possible within the current framework.

Why no OpenGL (yet)?
I received suggestions to pipe the video data directly into OpenGL. I decided not to go that route for this initial release. My primary goal was to keep the project accessible so people can experiment with it without needing deep knowledge of OpenGL. I might explore an OpenGL version in the future, but certainly not before I finish the Linux port.

Note: If anyone feels brave enough to take on the OpenGL implementation themselves, feel free to contribute! I’d welcome the collaboration.
Source Code & Licensing

In compliance with the LGPL license, I am including the C source codes for the bridge libraries. Inside the package, you will find:
  • 32-bit: qbvlc32.c, qbvlc.h and the compiled qbvlc32.dll64-bit: qbvlc.c, qbvlc.h and the compiled qbvlc64.dll.
Download & Important Note

The project is distributed as a ZIP file. Inside, you will find folders for 32-bit and 64-bit architectures. Please use the one that matches your QB64PE IDE version, otherwise, the VLC library calls will fail.

Download link: https://drive.google.com/file/d/1EGppFVK...sp=sharing
(The file is safe and shared directly from my personal storage.)
Happy coding and enjoy the holidays!


Reply
#37
(12-19-2025, 11:20 PM)Petr Wrote: I'll see what I can do about it, thanks for the suggestions. I'll look into it.
Seems you smacked it out the park bro! NICE! +1 from me! 

Unseen
Reply
#38
(12-20-2025, 10:22 PM)Petr Wrote: [Project Release] VLC-powered Media Player for QB64PE (Native Graphics & _SndRaw Sync)


Hi everyone,
I’m excited to announce the completion of a media player project for QB64PE that leverages the power of libVLC. This project utilizes the VLC libraries along with two custom-built bridge libraries that facilitate communication between the QB64PE environment and the VLC backend.
Key Technical Features:
  • Native Integration: Unlike many implementations that simply "overlay" a window on top of the IDE, this player renders video directly onto the QB64PE graphic screenAudio Handling: For audio output, I’m using_SndRaw Getting this to work was quite a challenge, but it allows for much tighter control within the QB64 environment.A/V Sync: I have implemented a synchronization logic that handles the timing between the video frames and the raw audio stream as efficiently as possible within the current framework.

Why no OpenGL (yet)?
I received suggestions to pipe the video data directly into OpenGL. I decided not to go that route for this initial release. My primary goal was to keep the project accessible so people can experiment with it without needing deep knowledge of OpenGL. I might explore an OpenGL version in the future, but certainly not before I finish the Linux port.

Note: If anyone feels brave enough to take on the OpenGL implementation themselves, feel free to contribute! I’d welcome the collaboration.
Source Code & Licensing

In compliance with the LGPL license, I am including the C source codes for the bridge libraries. Inside the package, you will find:
  • 32-bit: qbvlc32.c, qbvlc.h and the compiled qbvlc32.dll64-bit: qbvlc.c, qbvlc.h and the compiled qbvlc64.dll.
Download & Important Note

The project is distributed as a ZIP file. Inside, you will find folders for 32-bit and 64-bit architectures. Please use the one that matches your QB64PE IDE version, otherwise, the VLC library calls will fail.

Download link: https://drive.google.com/file/d/1EGppFVK...sp=sharing
(The file is safe and shared directly from my personal storage.)
Happy coding and enjoy the holidays!

This is.... 

WOW!!!!!

For ages and ages and ages and ages and ages and ages and ages and ages and....  WOWW!!!   For ages, I've been wanting to be able to play a vido file in QB64 directly onto the screen, without needing to resort to just shelling to a different program and having some sort of overlay on top of my window.   THIS does that, and it does it beautifully!

Only issue I ran into was having to decipher how to get it to actually run/play for me.  

If Len(mrl$) = 0 Then mrl$ = PathJoin$(base$, "A Bird in the Head.avi")      <-- This line here looks for a "terk.mkv" file normally.  There's no "terk.mkv" included with the package, so it runs for just a split second and then dies.

My suggestion?   Make this a _FILEOPENDIALOG interaction.  Then the user can easily browse their drive and find the suitable file.     

But the *only* change I had to do to make this work was copy my own video into the base folder, then change that line to point to my video the Three Stooges, and then I was off and running and watching/playing The Three Stooges on QB64!!

I'd love to see you distill this down to a simple plug-in *.BI and *.BM library for folks, with some basic commands for interaction.

Code: (Select All)
SUB PlayVideo (Control$)
    IF Control$ = "Play"  Then 'play video in area with current settings
    IF Control$ = "Pause" Then 'pause
    IF Control$ = "Position"  Then 'parse/set X/Y position
    IF Control$ = "Size" Then 'parse and set X2/Y2 position for size
'blah blah as needed so the main user interaction would be to just setting that control string and parsing it and it'd be that simple of an interface for the end user
END SUB

So then you'd do something like:

Code: (Select All)
'$INCLUDE:'Awesome_VLC_library.BI'

Screen _NewImage (800, 600, 32)
LoadVideo "Sexy Steve Twerking.mkv"
PlayVideo ("Position:100,100;Size:300,300;Play")
PlayVideo "Pause"
PlayVideo "Close"

'$INCLUDE:'Awesome_VLC_library.BM'

And the above would load the video, put it on the current screen from (100,100)to(400,400), and then play it.   Then pause/close it with the command after.  

If it was this simple to use, folks would be able to add all sorts of videos and cut sceens and such easily into their programs.

A HUGE thumbs up from me for this!!
Reply
#39
(12-20-2025, 11:03 PM)SMcNeill Wrote:
(12-20-2025, 10:22 PM)Petr Wrote: [Project Release] VLC-powered Media Player for QB64PE (Native Graphics & _SndRaw Sync)


Hi everyone,
I’m excited to announce the completion of a media player project for QB64PE that leverages the power of libVLC. This project utilizes the VLC libraries along with two custom-built bridge libraries that facilitate communication between the QB64PE environment and the VLC backend.
Key Technical Features:
  • Native Integration: Unlike many implementations that simply "overlay" a window on top of the IDE, this player renders video directly onto the QB64PE graphic screenAudio Handling: For audio output, I’m using_SndRaw Getting this to work was quite a challenge, but it allows for much tighter control within the QB64 environment.A/V Sync: I have implemented a synchronization logic that handles the timing between the video frames and the raw audio stream as efficiently as possible within the current framework.

Why no OpenGL (yet)?
I received suggestions to pipe the video data directly into OpenGL. I decided not to go that route for this initial release. My primary goal was to keep the project accessible so people can experiment with it without needing deep knowledge of OpenGL. I might explore an OpenGL version in the future, but certainly not before I finish the Linux port.

Note: If anyone feels brave enough to take on the OpenGL implementation themselves, feel free to contribute! I’d welcome the collaboration.
Source Code & Licensing

In compliance with the LGPL license, I am including the C source codes for the bridge libraries. Inside the package, you will find:
  • 32-bit: qbvlc32.c, qbvlc.h and the compiled qbvlc32.dll64-bit: qbvlc.c, qbvlc.h and the compiled qbvlc64.dll.
Download & Important Note

The project is distributed as a ZIP file. Inside, you will find folders for 32-bit and 64-bit architectures. Please use the one that matches your QB64PE IDE version, otherwise, the VLC library calls will fail.

Download link: https://drive.google.com/file/d/1EGppFVK...sp=sharing
(The file is safe and shared directly from my personal storage.)
Happy coding and enjoy the holidays!

This is.... 

WOW!!!!!

For ages and ages and ages and ages and ages and ages and ages and ages and....  WOWW!!!   For ages, I've been wanting to be able to play a vido file in QB64 directly onto the screen, without needing to resort to just shelling to a different program and having some sort of overlay on top of my window.   THIS does that, and it does it beautifully!

Only issue I ran into was having to decipher how to get it to actually run/play for me.  

If Len(mrl$) = 0 Then mrl$ = PathJoin$(base$, "A Bird in the Head.avi")      <-- This line here looks for a "terk.mkv" file normally.  There's no "terk.mkv" included with the package, so it runs for just a split second and then dies.

My suggestion?   Make this a _FILEOPENDIALOG interaction.  Then the user can easily browse their drive and find the suitable file.     

But the *only* change I had to do to make this work was copy my own video into the base folder, then change that line to point to my video the Three Stooges, and then I was off and running and watching/playing The Three Stooges on QB64!!

I'd love to see you distill this down to a simple plug-in *.BI and *.BM library for folks, with some basic commands for interaction.

Code: (Select All)
SUB PlayVideo (Control$)
    IF Control$ = "Play"  Then 'play video in area with current settings
    IF Control$ = "Pause" Then 'pause
    IF Control$ = "Position"  Then 'parse/set X/Y position
    IF Control$ = "Size" Then 'parse and set X2/Y2 position for size
'blah blah as needed so the main user interaction would be to just setting that control string and parsing it and it'd be that simple of an interface for the end user
END SUB

So then you'd do something like:

Code: (Select All)
'$INCLUDE:'Awesome_VLC_library.BI'

Screen _NewImage (800, 600, 32)
LoadVideo "Sexy Steve Twerking.mkv"
PlayVideo ("Position:100,100;Size:300,300;Play")
PlayVideo "Pause"
PlayVideo "Close"

'$INCLUDE:'Awesome_VLC_library.BM'

And the above would load the video, put it on the current screen from (100,100)to(400,400), and then play it.   Then pause/close it with the command after.  

If it was this simple to use, folks would be able to add all sorts of videos and cut sceens and such easily into their programs.

A HUGE thumbs up from me for this!!
Look, This aint my ball park but if all else fails ILL MAKE the GL version but think as I have a MASSIVE year long project im working on and dont in anyway want to be seen as a show off, will wait to be prompted! 

@Petr THIS DESERVES it's own thread!

Unseen
Reply
#40
Update #1 is here:
         
         Fixed Audio/Video synchronization: I’ve fixed the issue where audio and video would get out of sync when seeking
         (Left Arrow, Right Arrow, PgUp, PgDn). It now works correctly.
         BAS program update: The BAS program has been updated to include BI and BM files as suggested by SMcNeill. 
         Dynamic file loading: Following SMcNeill's suggestion, I am now using  _OpenFileDialog$, so there is no longer a need to 
         hardcode the video filename directly into the program.

          Installation: There is no need to redownload everything; you only need the attached ZIP file. It contains:
          New 32-bit and 64-bit DLLs.The updated BAS program (which now works with both versions).The source code for the DLLs.

          Instructions: Simply place the correct DLL for your system and the new BAS file into your project folder.


Attached Files
.zip   VideoPlayVLC_ALL_synchro_2.zip (Size: 136.28 KB / Downloads: 21)


Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)