Posts

Post not yet marked as solved
1 Replies
659 Views
Hi,Background: I am recording user screen with startCapture and stopCapture methods of ReplayKit. I have one AVAssetWriter with two AVAssetWriterInputs, one each for .video and .audioMic. Writer is set up for video .h264 (.mov) and audio LinearPCM. In the completion handler of finishWriting of the writer, I call a method which exports the recorded file(s) using exportSession. This export is failing randomly. Sometimes it works, sometimes don't.Upon debugging, I found out that the export fails whenever the AVAsset of the recorded file has NO tracks OR has only one track (i.e. either one of video or audio tracks). I did use loadAsynchronously method of AVAsset to make sure that tracks are loaded before the subsequent call, but it still returns the cases as before. So I suspected that the problem must be with the writer. I could confirm that the CMSampleBufferData gets appended to writerInputs correctly. And in the stopCapture completion block, both the writer inputs are marked as finished and finishWriting on the writer is called. So, I am not sure why there is indeterminate and random occurrences of this error, and how to resolve it.Error descriptionError Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open" UserInfo={NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x28885cc60 {Error Domain=NSOSStatusErrorDomain Code=-16976 "(null)"}}
Posted
by trymyui.
Last updated
.