AVAudioRecorder - 正确的MPEG4 AAC录制设置 [英] AVAudioRecorder - Proper MPEG4 AAC Recording Settings

查看:124
本文介绍了AVAudioRecorder - 正确的MPEG4 AAC录制设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实时应用,估计有15%的用户报告记录功能无效。这在我们的测试设备上没有发生,但报告显示问题是prepareToRecord返回NO。我很难找到AAC格式的样本设置。我的任何设置都关闭了吗?应用程序需要iOS5并使用ARC。

I've got a live app with an estimated 15% of users reporting that the record feature is not working. This isn't happening on our test devices, but the reports show that the problem is that prepareToRecord is returning NO. I've had trouble finding sample settings for AAC format. Are any of my settings off? App requires iOS5 and uses ARC.

 AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
 [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
 [NSNumber numberWithFloat:44100.0], AVSampleRateKey,
 [NSNumber numberWithInt:1], AVNumberOfChannelsKey,
 [NSNumber numberWithInt:AVAudioQualityHigh], AVSampleRateConverterAudioQualityKey,
 [NSNumber numberWithInt:128000], AVEncoderBitRateKey,
 [NSNumber numberWithInt:16], AVEncoderBitDepthHintKey,
 nil];

NSString *fileName = [NSString stringWithFormat:@"%@%@.caf", verseGUID, bRecordingReference ? @"_ref" : @""];
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", [[Utilities sharedInstance] documentsDirectoryPath], fileName]];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordSettings error:&error];
if([audioRecorder prepareToRecord]){
    [audioRecorder record];
}else{
    int errorCode = CFSwapInt32HostToBig([error code]);
    NSLog(@"Error: %@ [%4.4s])", [error localizedDescription], (char*)&errorCode);
}  


推荐答案

可能很多事情都没有与录音设置有关。

it could be many things not having to do with the recording settings.

您想要回答的真正问题似乎是:什么会导致录音不发生?

the real question you want answered seems to be: what would cause the recording not to occur?

audioRecorder可能是nil或者audioRecorder prepareToPlay可能返回NO。前者似乎更有可能。

audioRecorder could be nil or audioRecorder prepareToPlay could be returning NO. the former seems more likely.

传递给initWithURL的网址可能格式不正确:
- 您是否通过使用verseGUID,bRecordReference值进行测试?也许你的设备永远不会有坏的verseGUID,但没有录音的设备有一个零/空的verseGUID。这可能导致文件名只是.caf。

the url passed to initWithURL could be malformed: - have you tested by playing with the verseGUID, bRecordReference values? maybe your devices never have a bad verseGUID, but the devices on which no recording happens have a nil/empty verseGUID. this could cause the filename to be simply ".caf".

你似乎有自己的类方法[Utilities sharedInstance]。这可能是因为某些原因在你的设备上工作而不是在故障设备上?如果是这样,你可能会要求在你不想要的时候在顶级目录中录制。

you seem to have your own class method [Utilities sharedInstance] . could this work for some reason on your devices but not on the failing devices? if so, you could be asking to record in a top level directory when you did not mean to.

你能把你的测试人员带到测试版列表吗?注册一些像TestFlight或Hockey Kit这样的东西,让一个或多个记录失败的用户也注册,然后上传你的应用程序的测试版,其诊断信息会在屏幕上显示一个错误。这可能是最明显的。我使用testflightapp.com只是因为它是我尝试的第一个,我很容易管理并且对我的beta测试者来说非常轻松。

can you get the testers you have onto a "beta" list? sign up for something like TestFlight or Hockey Kit, get one or more of the users with a failure to record to also sign up, and then upload a beta of your app with diagnostics that put a dialog on screen with the resultant "error". that might be most obvious. i use testflightapp.com only because it was the first i tried, it was pretty easy for me to manage and pretty painless for my beta testers.

这篇关于AVAudioRecorder - 正确的MPEG4 AAC录制设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆