LLSimpleCamera:AVAssetWriterInput appendSampleBuffer 崩溃

LLSimpleCamera : AVAssetWriterInput appendSampleBuffer crashing

我正在使用 LLSimpleCamera 录制视频。当我使用后置摄像头时录制正常,但是当我切换到前置摄像头时,应用程序崩溃并报告错误

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[AVAssetWriterInput appendSampleBuffer:] Media type of sample buffer must match receiver's media type ("soun")'

我已经尝试了很多 Whosebug 帖子,但无法修复崩溃。谁能告诉我可能是什么问题?

问题的答案是:

Changing AVCaptureDeviceInput leads to AVAssetWriterStatusFailed

感谢 Whosebug。

尝试添加以下检查

if ([connection.output connectionWithMediaType:AVMediaTypeVideo] == nil)

并检查相机的前后状况