I am doing screen capture with AVCaptureScreenInput. The app has a window with configuration options.
I want to record the screen but not record the window in the recorder application. Quicktime does this if you do a screen recording, as an example.
I think I found what will do it, but I'm not sure how or if they can be used together.
kCGWindowListOptionOnScreenBelowWindow is found in CGWindow.h in the Core Graphics framework. AVCaptureScreenInput is part of AVCaptureInput.h in the AVFoundation framework.
If you are taking a single screenshot, you can pass kCGWindowListOptionOnScreenBelowWindow and a windowID so that only windows below that window's level are captured. I can accomplish my goal by setting the capture app's window to a very high level if this works.
I'm relatively new to Objective-c ands its not clear to me if its possible to use the kCGWindowListOptionOnScreenBelowWindow with AVCaptureScreenInput. If it is, could someone provide tips on what the resulting code needs to look like?
How to access the pixel buffer of an NSWindow in OSX?
As far as I know, there is no way to exclude specific windows from OS X's built-in display recording APIs:
Both above methods seem to grab the screen content after compositing, when the final screen output has already been composited together.
So excluding your recording window would require you to use an API that allows you to composite the windows yourself and later append those custom frames to an AVAssetWriterInput.
Quartz Window Services allow you to take snapshots of single windows via CGWindowListCreateImage. A good sample project that also shows how to composite multiple window shots together is Son of Grab.
After retrieving the stitched together shot, you'd have to append it to an AVAssetWriterInput. AVFoundation provides a convenience class to append custom pixel buffers to a movie: AVAssetWriterInputPixelBufferAdaptor.
Especially the AVFoundation part could become very frustrating and you might run into performance problems as the compositing is very likely to be slower than OS X's built-in compositor, but overall it should be possible to to achieve what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With