AFathi / ARVideoKit

Capture & record ARKit videos 📹, photos 🌄, Live Photos 🎇, and GIFs 🎆.
Apache License 2.0
1.63k stars 227 forks source link

App crashes when user tries to start record when using Skype (or other mic related app) #22

Open pionl opened 6 years ago

pionl commented 6 years ago

The crash:

Fatal Exception: NSInvalidArgumentException *** -[AVAssetWriterInput initWithMediaType:outputSettings:sourceFormatHint:] 4 is not a valid channel count for Format ID 'aac '. Use kAudioFormatProperty_AvailableEncodeNumberChannels (<AudioToolbox/AudioFormat.h>) to enumerate available channel counts for a given format.

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x186d31d04 __exceptionPreprocess
1  libobjc.A.dylib                0x185f80528 objc_exception_throw
2  AVFoundation                   0x18c5c5a04 -[AVAssetWriterInput dealloc]
3  ARVideoKit                     0x101bac6bc (Missing)
4  ARVideoKit                     0x101bacd8c (Missing)
5  ARVideoKit                     0x101bb41b4 (Missing)
6  AudioToolbox                   0x18a94be60 AudioSessionRequestRecordPermission
7  AVFAudio                       0x18c4e5d18 -[AVAudioSession requestRecordPermission:]
AFathi commented 6 years ago

@pionl,

Due to some limitation in iOS, you cannot use a microphone while it's being used by another application (e.g. FaceTime, Skype, Phone... etc.). However, there's a workaround this issue in order to enable recording videos while using Skype or similar apps.

Although you'll be able to record a video, the video won't have any audio included. To make this happen, you will have to disable the audio recording by setting enableAudio to false when the device's microphone isn't available.

I may be able to assist you in code if you share a snippet of your code.

-Ahmed

pionl commented 6 years ago

Hi Ahmed,

I thought it will be the issue. Unfortunately I didn't find any code that would allow me to detect if the microphone is already used. Do you have any code for it?

Also I'm trying to use Voicemod which uses microphone too (same error), is there any way to feed wav file and the end to the video? (on stop). Only if there is post processing in the library. Otherwise I would need to merge the audio / video at the end.

Thank you, Martin

pionl commented 6 years ago

@AFathi How you founded any code?

anushkmittal commented 6 years ago

bump. I was wondering if a integrate solution within the framework would be a better choice!