QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: NOVARSEG on June 03, 2021, 04:34:34 am
-
Can MEM access video ram when a you tube video is playing?
maybe something like the DOS TSR?
-
Not sure, but that sounds absolutely dangerous and would most likely require a great deal of knowledge on codecs. You could use my WinAPI code for recording webcams through QB64 and then use a virtual webcam to pipe in the desktop video feed.
-
You could always use _SCREENIMAGE with the SAVEIMAGE code to "grab" frames from the video while it is playing.
-
https://www.qb64.org/forum/index.php?topic=561.msg4127#msg4127
try it, first run video on youtube, then run this program.
For start recording press spacebar. After then is program minimalized (but is recording frames from screen on selected area to Ram in background)
For end recording click to tray to program icon, this maxcimalize this program, then press enter for end recording frames from screen.
Press any key for playing recorded content.
For saving frames from RAM to HDD use SaveImage by Steve (not implanted in this program).
-
just as Cobalt suggested. I created a program using SCREENIMAGE that allows you to draw a box around the video area on your desktop you want to capture then saves each frame to an array to be played back or saved as a bitmap. at startup you specify the frame rate to capture so when you play it back it is rendered the original speed. I created it because I was looking for a way to save video clips that can be used for playback in my programs, works great!... Actually, I used it to create the 'Skull.png' image sheet that I'm currently using with my '3D skull from 2D images' program, I captured it from a GIF of the rotating skull, I will find and post it just for fun. of course, the skull was not for video playback but to analyze each frame for 3D.
I ALSO created a version that will freak you out that is too hard to explain here, better to show you, I'll make a video demo in the next few days and post it as well
-
I made. .DLL in purebasic once to allows a QB64 window to open/display a webpage. Like a browser window. Haven’t tried this, but maybe it would be possible to do a _COPYIMAGE(_DISPLAY) while watching a YouTube video with such a QB64 window. If your interested I can dig up that .DLL (it was on my older laptop that died but I backed up the data somewhere). It was 32-bit though.
- Dav
-
OldsCool
then saves each frame to an array to be played back or saved as a bitmap.
as the video is playing, how does the code know when to read video ram?
My experience with video stuff is limited. I wrote an AVI file reader for Canon power shot camera. The (Canon) AVI format is fairly complex - it has variable compression. Every video frame can be a different length. There is one sound frame per 30 video frames. The sound frame is always the same length.
-
_SCREENIMAGE essentially returns the headless BMP format. So the frame size in RAM is determined as the selection width multiplied by the selection height multiplied by 4 bytes because you store 32-bit frames. Only pointers to individual frames that are created using the _COPYIMAGE or _NEWIMAGE command (depending on how the program is built) are stored in the field.
You can also determine the size of the block of memory that the image takes up as follows:
Frame = _SCREENIMAGE
Dim M as _Mem
M = _MemImage (Frame)
Print M.Size
For accurate playback synchronization, if you have 25 frames per second recorded, use _Limit 25 between each frame (Actually, you will use the same when recording images to RAM)
-
I don't know enough about this subject to give any good reply. If a video is playing on a certain window and QB64 on another window then how does the QB64 program run at the same time as the video player. Does that involve multithreading?
-
I don't know enough about this subject to give any good reply. If a video is playing on a certain window and QB64 on another window then how does the QB64 program run at the same time as the video player. Does that involve multithreading?
What video player are you using by the way?
So you don't listen to music or anything while your working on code in qb64?
I could walk you through it, but it sounds like @OldsCool has a program that might be already created and work for you. might ask him for a link.
-
How does it work? QB64 simply captures the current screen, no matter what is running on it. Therefore (in the link I added last time above) I minimize the screen capture program so that its window does not overlap what is happening on the screen being recorded. Therefore, it records everything even when switching to another program, it captures exactly what is currently on the screen. If you only want to scan the output of a specific program, whether it is currently visible or not, you would probably have to use some Windows functions using dynamic libraries, I haven't tried this yet and I don't know if it's possible at all.
Keep in mind that the program I wrote a few years ago doesn't worry about synchronization, it's just the roughest resource for testing the principle of operation.
-
What would happen if 2 QB64 programs were to access video ram at the same time?
Say, a QB64 program writes a pixel and then the other QB64 program reads that same pixel. Can this be kept in sync?
The test
the first program writes a green pixel and then a red pixel at the same location. The second program reads the same pixel location after every write of the first program. The second program should read alternating red -green pixels. If it reads the same color twice (or other colors) in a row you know it went out of sync.