AVAudioRecorder Settings did not take effect on output file

只愿长相守 提交于 2019-12-11 18:37:13

问题


I'm using AVAudioRecorder to record and save to an audio.m4a file with these settings:

NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
    [recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityMin] forKey:AVEncoderAudioQualityKey];
    [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
    [recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVEncoderBitRateKey];
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
    [recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
    [recordSetting setValue:[NSNumber numberWithInt:8] forKey:AVLinearPCMBitDepthKey];

But when I use a software to read the attributes of audio.m4a file, I got these:

Bitrate: 64KBps

Channels: 2

So does that mean those settings above did not affect the output file, because obviously, I set its bit rate to 16 and channels to 1. Did I miss something on these settings??


回答1:


The problem is that not every setting is legal and illegal settings fail silently. So in this case a bitrate of 16 is way too low. In a sense, the system is doing you a favor; instead of barfing, it's making the recording, but it's substituting legal settings for the ones you gave.



来源:https://stackoverflow.com/questions/22650161/avaudiorecorder-settings-did-not-take-effect-on-output-file

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