2014-11-27 12 views
5

Il mio codice ha funzionato fino a iOS 8 kAudioFormatMPEG4AAC ma ora crea un file vuoto. Non sono stati segnalati errori Quando l'ho cambiato in kAudioFormatLinearPCM funziona. Questo è il mio codice:AVAudioRecorder in iOS 8 non gestisce kAudioFormatMPEG4AAC

recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: 
    [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey, 
    [NSNumber numberWithInt: kAudioFormatLinearPCM], AVFormatIDKey, 
    [NSNumber numberWithInt:16], AVEncoderBitRateKey, 
    [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, 
    [NSNumber numberWithFloat:32000.0], AVSampleRateKey, 
    nil]; 

risposta

3

Rimuovere AVEncoderBitRateKey chiave dal vostro dizionario impostazioni e funziona su iOS 8 con kAudioFormatMPEG4AAC.

Potrebbe essere una correlazione specifica tra AVEncoderBitRateKey e AVNumberOfChannelsKey. Ma non ho giocato con i parametri ma ho usato il valore di bitrate predefinito per ottenere un registratore funzionante.

3

Questo bitrate sembra sospettosamente basso, anche per kAudioFormatMPEG4AAC (16 byte al secondo), forse provare 16000 o 64000 o più.

p.s. provare i nuovi letterali Objective-C per il vostro NSDictionarys, NSArrays e NSNumbers, penso che siano un miglioramento: la registrazione

recordSettings = @{ 
    AVEncoderAudioQualityKey : AVAudioQualityMin, 
    AVFormatIDKey : @(kAudioFormatLinearPCM), 
    AVEncoderBitRateKey : @16000, 
    AVNumberOfChannelsKey : @1, 
    AVSampleRateKey : @32000 
}; 
+0

Con kAudioFormatLinearPCM, il mio AVAudioRecorder non funziona. –