将音频文件录制为 mp3 或 wav
我正在尝试录制并保存 mp3 文件,因此我使用以下代码
NSString* d = @" ar/mobile/Applications/86F15C5E-66EC-4071-95EB-96CDE64B5948/Library/Application Support/P/5720/5720/Report/Report0.mp3"
NSURL *soundFileURL = [NSURL fileURLWithPath:d];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
}
并开始录制我
[audioRecorder record];
用于 mp3 的文件,但出现错误 错误:操作无法完成。 (OSStatus错误1718449215。)
如果我将其保存为wav,则不会记录任何内容,并且文件为0字节,
我是否丢失了某些内容,知道如何解决这个问题
I am trying to record and saave mp3 file so I use the following code
NSString* d = @" ar/mobile/Applications/86F15C5E-66EC-4071-95EB-96CDE64B5948/Library/Application Support/P/5720/5720/Report/Report0.mp3"
NSURL *soundFileURL = [NSURL fileURLWithPath:d];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
}
and to start record I use
[audioRecorder record];
for mp3 I got error
error: The operation couldn’t be completed. (OSStatus error 1718449215.)
and if I saved it as wav nothing be recorded , and the file be 0 byte
am I missing something , any idea how to solve that
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有展示 Dpath 的定义方式......
you're not showing the way Dpath is defined...
也许将其保存到文档文件夹中?这不是正确的合法途径吗?
perhaps save it to the documents folder? Isn't that the correct legal path?