我从Novocaine的示例项目中输出了一个m4a文件。但我无法在iTunes中打开该文件。文件可能已损坏。
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
@"My Recording.m4a",
nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
NSLog(@"URL: %@", outputFileURL);
self.fileWriter = [[AudioFileWriter alloc]
initWithAudioFileURL:outputFileURL
samplingRate:self.audioManager.samplingRate
numChannels:self.audioManager.numInputChannels];
__block int counter = 0;
self.audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) {
[wself.fileWriter writeNewAudio:data numFrames:numFrames numChannels:numChannels];
counter += 1;
if (counter > 800) { // roughly 5 seconds of audio
wself.audioManager.inputBlock = nil;
}
};我没有更改代码,只是删除了注释。
如果您知道可能的解决方案或建议,我想知道您是否可以与我分享。
发布于 2013-11-20 13:37:17
这里讨论了这个问题:https://github.com/alexbw/novocaine/issues/59
原始代码使用下面这一行(在处理程序块中)结束记录:
wself.audioManager.inputBlock = nil;我在后面紧跟着添加了下面这一行,让它正常工作:
[wself.fileWriter stop];AudioFileWriter的stop方法是私有的,因此还需要将其添加到公共接口。
https://stackoverflow.com/questions/17768478
复制相似问题