AVAssetWriter record settings not working like AVAudioRecorder

蹲街弑〆低调 提交于 2019-12-11 18:00:47

问题


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];

回答1:


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



来源:https://stackoverflow.com/questions/11191403/avassetwriter-record-settings-not-working-like-avaudiorecorder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!