AVAssetWriter recording settings do not work like AVAudioRecorder

I have successfully used these recording options to create the audio format in the desired format. However, these settings seemed to work with AVAudioRecorder. When I try them using AVAssetWriter, I get an error message indicating that AVLinearPCMBitDepthKey needs AVLinearPCMBitFloatKey, but when I add that it says it is not allowed for 'ulaw'. My question is: why does AVLinearPCMBitDepthKey work fine on one recorder, but not on the other?

[recordSettings setObject:[NSNumber numberWithInt: kAudioFormatULaw] forKey: AVFormatIDKey]; [recordSettings setObject:[NSNumber numberWithFloat:8000.0] forKey: AVSampleRateKey];//was 44100.0 [recordSettings setObject:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; [recordSettings setObject:[NSNumber numberWithInt:8000] forKey:AVEncoderBitRateKey];//was 64000 [recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityLow] forKey: AVEncoderAudioQualityKey]; 
0
source share
1 answer

Apple support: this is therefore an error - the file was created, the number of samples was successfully written, and the append starts to crash for an unknown reason.

Error only with these settings and AVAssetWriter

AudioQueue is what you should use for external sound

0
source

All Articles