Viewport capture from within another extension?

Is there a way to record what’s happening in the viewport from within a custom extension? The MovieCapture extension has the functionality I want but only seems to be accessible as a GUI, and so using it from another extension seems very difficult.

look into the script of omni.kit.window.movie_capture to see how it uses omni.kit.capture.viewport to do the capture. When designing the capture feature, we considered this kind of needs so omni.kit.capture.viewport was the one to provide the capture API, and omni.kit.window.movie_capture was to expose omni.kit,capture.viewport’s capture API to end users.