How does OBS captures OpenGL based games video on Windows? - windows

I am trying to capture screenshots for OpenGL based games on Windows. Most answers on the internet are to make the window visible and take screenshots. But when I use OBS(Open Broadcaster Software) to broadcast my game play, it is able to streaming the game content even the game window is minimized.
Can anyone help me understand how they do that?
Thanks!

The OpenGL API provides a way to draw to an internal "Frame buffer object" (FBO) which can be blitted to the window. If OBS doesn't provide a way to access that FBO, then your only solution is to make the window visible. Well, you could also hack the broadcast and try to figure out about those bytes...
EDIT:
When the OP clarified his question I was curious. So I dug into OBS code and found that for Windows it uses .dll injection and process hook.
I also found that it hooks "swap buffers" and get the current Frame Buffer with glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING...), copies it and then let Windows continues its job.
Please, notice that I can be wrong. But what I found looks good to me.

Related

Managing no-client area

I've been searching a long time ago for a manner to enhance and skin the no-client area in windows, and many people say that there are only two ways, either you make a frame-less window and draw my own buttons or by hooking windows message like WM_PAINT, and I'm interested in the second approach, so is there anyway to achieve that because the big problem is that I'm using Qt, and maybe this photo will help emphasizing the problem.
What you're looking for is Non-client painting. Windows has a number of messages for handling the non-client area. Doing some web searches for 'QT Non-client paint' results in this thread, which gives a brief example of how to do non-client painting in QT.
Adobe Brackets (specifically the CEF wrapper source code, found here: https://github.com/adobe/brackets-shell/) provides source code for non-client painting; Spotify shares this code (see credits). I do not have experience with doing this in Qt; I tinkered with a 64-bit port of brackets-shell but didn't finish as I started playing with Electron. It's Windows specific, so maybe you could use Win32 API directly to wrap the Qt window's WndProc and implement that way?

Using external video hardware - beginner needs directions

I have a little application here which deals with QuickTime video using QTKit.
This is my first Cocoa app, so I'm still pretty new to programming for OS X.
As the main stuff is now working, I was wondering how I could use and support external video hardware?
I just don't have a clue how to get started as I have never worked with external hardware before.
So, if there is a BlackMagic card installed in the machine the program is running on for example, how would I get to know that and how would I possibly have my QuickTime movie played out on this card instead of a QTMovieView on the computer monitor?
Would be glad if someone could point me a direction!
Thank you very much.
The kind of graphics cards you have installed shouldn't matter to QTKit when it comes to playing things back (it might look smoother and sexier to you, but to what you call in the operating system it doesn't matter).
To display content on a second monitor (or "external hardware", as you call it), you can get information on the various screens hooked to your Macintosh by calling [NSScreen screens]. Take a look at the rest of the NSScreen reference, too.
And once you get the hang of that, you can decide if you want to do full screen on the deepest screen (presumably the one with your expensive graphics card), or if you want to render on the largest screen (which you can determine from NSScreen's "frame" method), or the screen that isn't the "main screen" with the menu bar.
There's also lower level stuff available for you to use in Quartz. Here is Apple's "Quartz Display Services Reference" guide. I'd only recommend going this route when you feel sufficiently smart with Macintosh program to go deeper.
Hope this helps you out!

can we get window handle of the window which is playing video?

Is there any way to get window handle of the window which is currently playing video. This is the only information my program will be having.
updated to include info incorrectly provided as an answer
I think I should explain what exactly I want to achieve here.
I actually wanted to share/stream my DVD data to the remote machine. Currently what I am doing is, I am capturing the screen/video into to still frames and sending it to remote system but now I don't want to see the playing video on my host machine. I could think of few probable solutions,
1.) If we can capture the data of a hide/minimized window.
Did some investigation and seems it is not possible. Please add your thoughts.
2.) Convert the DVD data format into ffmpeg format and stream it.
Don't have any idea if we will be allowed to convert the data format. If most of the DVD formats allow to covert then I can go for this option but not sure how complicated it could be.
3.) Will create some virtual surface play the DVD data to that surface and capture the screen of that surface.
Again not sure if DVD will play on that virtual/fake surface created by kernel mode driver.
There are probably three main playback engines used on windows; DirectShow (WMP, MPC) , ffmpeg (VLC, MPlayer) and QuickTime.
If you look closer at DirectShow will will see that it supports hardware overlays, windowed and windowless rendering and Direct3d surface support.
Even if you focus on a single app you are going to have problems since you don't know what kind of renderer is in use. You might be able to find a child window that always has the same position and dimensions as the video, but then you are relying on things that could change between versions etc.

OpenCV camera stream stopping while in fullscreen mode

I want to have two aplications simultaneously run: one that analyzes image from webcam written using OpenCV (the image is acquired through callback function) and an application that goes into fullscreen mode (let's say a 3D game). The problem is that while the fullscreen mode is launched the webcam image stream is stopping - the frames simply don't turn up, the callback function isn't called. This seems to be an issue with OpenCV - to test that a simple application displaying the image form camera has been prepared.
Why the image stream could be blocked by the fullscreen mode? How to bypass this?
Thanks for any hints.
Your question does not tell if you have tried to search for the problem in the OpenCV community first, so I post this as a hint in case: http://tech.groups.yahoo.com/group/OpenCV/
Also check out the list of issues, maybe its a known bug: https://code.ros.org/trac/opencv/report/1
I'm not an OpenCV expert so this is closer to a suggestion than an answer - but I've experienced similar on my multi-monitor setup using a number of media players on the second monitor and some fullscreen apps ont he first.
In my limited testing, it comes down to what method is used to render the 3d app - DirectX seems to stop media players, OpenGL doesn't.
So it might not be OpenCV which has a problem - it may be what DirectX does to the hardware during a full-screen game.
Actually the behaviour of the OpenCV camera stream is strange. It seems to depend on the native OpenCV window (cvNamedWindow()) that shows the output image form webcam. If the window is on the same screen that went fullscreen the streaming will continue. If the camera window would be placed on another screen, the stream would stop.
Another curious thing is with the screen resolution change. If you change the resolution of the screen and the camera window is not visible (is closed or even minimalized) the image stream would get blocked.
These are just my observations on the topic, maybe it'll be helpful for someone.

How easy is it in DWM to make an 'always on top' thumbnail for an existing window

I really like when you hover over a window in Vista on the taskbar and it gives you a little preview. if it is video it even plays in the thumbnail.
Often I really wish I could 'tear off' this little window and keep it as an 'always on top' thumbnail on my screen. Maybe its a progress bar I'm watching, maybe its a video i want a little tiny preview of.
Isn't this the kind of thing that DWM makes it easy to program. Would this be a simple endeavor to program in nice managed C# - or would i end up getting all bogged down in tricky API stuff?
I am interested in both existing solutions and pointers on how to code something like this.
Sorry for the self-promotion here. :)
Just mentioning there's already an app that allows you to clone every top-level window and keep their preview "always on top": OnTopReplica.
The program is based on the Windows Forms Aero library, a .NET (c#) library that includes some DWM wrappers. No tricky API stuff needed (besides, the API is pretty simple anyway).
A very good preview of how to use this in C#:
http://community.bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx
Yes, you can create your own taskbar-like thumbnails. You're going to have to do quite a bit of window handle manipulation though. How it works is basically that you create a child-window in your form that will be the thumbnail. You obtian the window handle of the top-level window you want a thumbnail of using the usual tricks. Then you call a DWM function DWMRegisterThumbnail to associate the two. You don't actually get involved in painting the thumbnail at all - once the windows are associated, the DWM compositing process takes care of painting a thumbnail of the top-level window in your form.
MSDN Documentation

Resources