![]() |
|
Dynamic Libraries (Windows) - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Prolific Programmers (https://qb64phoenix.com/forum/forumdisplay.php?fid=26) +---- Forum: Petr (https://qb64phoenix.com/forum/forumdisplay.php?fid=52) +---- Thread: Dynamic Libraries (Windows) (/showthread.php?tid=4197) |
RE: Dynamic Libraries (Windows) - Unseen Machine - 12-19-2025 (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.Windows reports a virus!!!! RE: Dynamic Libraries (Windows) - Petr - 12-19-2025 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. RE: Dynamic Libraries (Windows) - Unseen Machine - 12-19-2025 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 RE: Dynamic Libraries (Windows) - Petr - 12-19-2025 I'll see what I can do about it, thanks for the suggestions. I'll look into it. RE: Dynamic Libraries (Windows) - Pete - 12-19-2025 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
RE: Dynamic Libraries (Windows) - Petr - 12-20-2025 [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:
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:
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/1EGppFVK53PRIAib0VrVgUQgB4PlfHohp/view?usp=sharing (The file is safe and shared directly from my personal storage.) Happy coding and enjoy the holidays! RE: Dynamic Libraries (Windows) - Unseen Machine - 12-20-2025 (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 RE: Dynamic Libraries (Windows) - SMcNeill - 12-20-2025 (12-20-2025, 10:22 PM)Petr Wrote: [Project Release] VLC-powered Media Player for QB64PE (Native Graphics & _SndRaw Sync) 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$)So then you'd do something like: Code: (Select All) '$INCLUDE:'Awesome_VLC_library.BI'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!! RE: Dynamic Libraries (Windows) - Unseen Machine - 12-20-2025 (12-20-2025, 11:03 PM)SMcNeill Wrote: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!(12-20-2025, 10:22 PM)Petr Wrote: [Project Release] VLC-powered Media Player for QB64PE (Native Graphics & _SndRaw Sync) @Petr THIS DESERVES it's own thread! Unseen RE: Dynamic Libraries (Windows) - Petr - 12-21-2025 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. |