如何在iOS上以超低比特率录制音频?

时间:2017-01-23 03:54:59

标签: ios avfoundation audio-recording avaudiorecorder

我一直在尝试使用AVAudioRecorder在iOS上录制音频。以下是我在iOS 10.0.2,iPhone 6上尝试过的一些设置。

16khz, 1 channel, CBR, AVAudioQualityMin, 8000 bitrate - didn’t record
16khz, 1 channel, CBR, AVAudioQualityMin, 8192 bitrate - didn’t record
16khz, 1 channel, CBR, AVAudioQualityMin, 10000 bitrate - didn’t record
16khz, 1 channel, CBR, AVAudioQualityMin, 10000 bitrate/channel - didn’t record
16khz, 1 channel, CBR, AVAudioQualityMin, 11264 bitrate/channel - didn’t record

(only 2 successful recordings)
16khz, 1 channel, CBR, AVAudioQualityMin, 12000 bitrate/channel - 69s, 113KB 1.63KB/s 
16khz, 1 channel, constant, Min, 12000 bitrate - 31s, 51KB 1.6KB/s

这是初始化设置的代码

- (void)_initRecorderSettings
{
    self.recorderSettings = ({
        NSMutableDictionary *settings = [[NSMutableDictionary alloc] init];
        [settings setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC]
                    forKey:AVFormatIDKey];
        [settings setValue:[NSNumber numberWithFloat:12000.0]
                    forKey:AVSampleRateKey];
        [settings setValue:[NSNumber numberWithInt:1]
                    forKey:AVNumberOfChannelsKey];

        // Encoder
        [settings setValue:[NSNumber numberWithInt:AVAudioQualityMin]
                    forKey:AVEncoderAudioQualityKey];
        [settings setValue:[NSNumber numberWithInt:12000]
                    forKey:AVEncoderBitRateKey];
        [settings setValue:AVAudioBitRateStrategy_Constant
                    forKey:AVEncoderBitRateStrategyKey];
        settings;
    });
}

这是录制的代码

   if (self.isRecording) {
        return;
    }

    NSError *recorderInitError;
    self.audioRecorder = [[AVAudioRecorder alloc] initWithURL:outputFileUrl
                                                     settings:self.recorderSettings
                                                        error:&recorderInitError];
    if (recorderInitError) {
        return;
    }

    self.isRecording = [self.audioRecorder record];

在提及“没有记录' - [self.audioRecorder record];返回FALSE。 (recorderInitError始终为零)

我希望能够以8kbps的速度录制,为什么我无法录制?如果不可能,VBR可以帮助减小录制文件的大小吗?

0 个答案:

没有答案