Is it possible to simultaneously record from microphone and camera?

While capturing the screen, can we mix in microphone input? Taking that further, is it possible to capture from camera at the same time?

Replies

You would use multiple different APIs for this purpose. For both microphone and camera input, you could use AVCapture, and then use ScreenCaptureKit's synchronizationClock to make sure everything is synched. Alternatively, something like AVAssetWriter should handle synchronization automatically.

  • I have done this, but in my test, I found that shortly after toggling Capture Audio and update the stream, the AVAssetWriter will give me an error getSubtractiveDecodeDuration signalled err=-16364 (kMediaSampleTimingGeneratorError_InvalidTimeStamp) (Decode timestamp is earlier than previous sample's decode timestamp.). This will lead to my output video file unplayable. I have no idea how to fix this.

Add a Comment

I see the same error getSubtractiveDecodeDuration signalled err=-16364 (kMediaSampleTimingGeneratorError_InvalidTimeStamp) (Decode timestamp is earlier than previous sample's decode timestamp.) occasionally. Most of the time using AVAssetWriter seems to work fine. @LiYanan04818 did you ever figure out a solution