9

I am using LLSimpleCamera for recording a video. It's recording fine when I use rear camera but when I switch to front camera, app crashes and the error reported is

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

I have tried many of the stackOverflow posts but not able to fix crash. Can anyone let me know what can be the issue ?

Preetika
  • 702
  • 8
  • 21
  • The error message gives you a spot to start -- the sample buffer in question is 'soun' (audio). Since the error is a media type mismatch, it would appear you're appending the "wrong" input buffer (or at least not the one you think you are) after you change the device states. It may be useful for you to walk through what devices are doing what when you make the switch and if you still haven't solved it, post the code where you are setting up the devices, capturing the buffers, changing the input device, and doing the buffer appends. – Brad Brighton Feb 01 '19 at 20:13

2 Answers2

2

The answer to the question is :

Changing AVCaptureDeviceInput leads to AVAssetWriterStatusFailed

Thanks to Stackoverflow.

Preetika
  • 702
  • 8
  • 21
0

Try to add below check

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

and also check front and rear conditions for the camera

Pragya Singla
  • 244
  • 3
  • 13