Tôi đang triển khai bản ghi âm. Nó hoạt động tốt với định dạng caf
& wave
. Nhưng vấn đề là kích thước tệp quá lớn.iOS: Định dạng tệp ghi âm âm thanh
Vì vậy, bất kỳ ai cũng có thể giúp tôi để ghi lại âm thanh có định dạng cũng được phát trong cửa sổ & kích thước tệp thấp.
Mã tôi đã cố gắng là dưới đây:
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"sound.wave"];
NSLog(@"%@",soundFilePath);
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:8000.0], AVSampleRateKey,
[NSNumber numberWithInt:8], AVLinearPCMBitDepthKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
}
trùng lặp của http://stackoverflow.com/questions/4279311/how-to-record-voice-in-m4a-format? – nneonneo
Ghi ở định dạng m4a (MPEG-4 AAC). Xem http://stackoverflow.com/questions/4279311/how-to-record-voice-in-m4a-format để biết chi tiết. – nneonneo