Search code examples
objective-cswiftmacosnsviewavcapturesession

How to capture App Screen as Video with Audio in Mac OSX?


I am writing a MacOS or OSX application where I need to record only the View of my application (Not the Whole display) with the Audio it emits.

Think it as a game app and I need to record the complete GamePlay View Of the Application.How should I go about doing this?

I am aware of "AVCaptureScreenInput" and, the example. But how to capture only the view of my application?


Solution

  • From the website you posted:

    Note: By default, AVCaptureScreenInput captures the entire screen. You may set its cropRect property to limit the capture rectangle to a subsection of the screen.

    Just set this property to the windows/views rect and you're done

    Of course you need to update and restart the recording when the windows/views rect changes.