问题描述
我已经成功地使用这些记录设置,以创建格式化成需要的格式的音频。但是,这些设置仅似乎随着AVAudioRecorder工作。当我尝试他们AVAssetWriter我得到一个错误,指出AVLinearPCMBitDepthKey需要AVLinearPCMBitFloatKey但是当我补充一点,它说,它不会允许'ULAW。我的问题是为什么AVLinearPCMBitDepthKey做工精细在一个记录而不是其他?
[recordSettings的setObject:[NSNumber的numberWithInt:kAudioFormatULaw] forKey:AVFormatIDKey];
[recordSettings的setObject:[NSNumber的numberWithFloat:8000.0] forKey:AVSampleRateKey]; //是44100.0
[recordSettings的setObject:[NSNumber的numberWithInt:1] forKey:AVNumberOfChannelsKey];
[recordSettings的setObject:[NSNumber的numberWithInt:8000] forKey:艾文coderBitRateKey]; //是64000
[recordSettings的setObject:[NSNumber的numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
[recordSettings的setObject:[NSNumber的numberWithInt:AVAudioQualityLow] forKey:艾文coderAudioQualityKey]。
每苹果支持:
因此,这是错误 - 在创建文件,样本数量都成功写入然后追加失败开始为一些未知的原因
该错误只似乎与这些设置和AVAssetWriter
发生AudioQueue是应该用于ULAW音频
I have successfully used these recording settings to create audio formatted into the needed format. However these settings only seemed to work with AVAudioRecorder. When I try them with AVAssetWriter I get an error stating that the AVLinearPCMBitDepthKey needs AVLinearPCMBitFloatKey but when I add that it says its not allowed for 'ulaw'. My question is why does AVLinearPCMBitDepthKey work fine in one recorder but not 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];
Per Apple support: this is therefore the bug -- the file is created, a number of samples are written successfully then append starts failing for some unknown reason.
The bug only seems to happen with these settings and AVAssetWriter
AudioQueue is what should be used for ulaw audio
这篇关于AVAssetWriter记录设置工作不喜欢AVAudioRecorder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!