几周前,我发布了一篇关于我在AVAssetWriter:AVAssetWriter Woes中遇到的问题的帖子。
进一步的研究似乎会导致在使用AVAssetWriter与AVAudioPlayer或真正的任何音频系统播放音频时发生冲突。我也和OpenAL试过了。
以下是背景:
使用CVPixelBufferPoolCreatePixelBuffer.
您可以在这里下载具有代表性的项目:http://www.mediafire.com/?5k7kqyvtbfdgdgv
注释掉AVAudioPlayer播放,它将在设备上工作。
任何线索都很感激。
发布于 2011-07-24 16:43:31
我已经找到了解决这个问题的办法。
如果您想让AVAudioPlayer和AVAssetWriter一起正确运行,您必须有和音频会话类别是“混合的”。
您可以使用一个可以混合的类别,比如AVAudioSessionCategoryAmbient。
但是,我需要使用AVAudioSessionCategoryPlayAndRecord。
通过实现以下操作,可以将任何类别设置为混合:
OSStatus propertySetError = 0;
UInt32 allowMixing = true;
propertySetError = AudioSessionSetProperty (
kAudioSessionProperty_OverrideCategoryMixWithOthers, // 1
sizeof (allowMixing), // 2
&allowMixing // 3
);发布于 2014-01-19 16:57:39
以上的答案是完整的。它不起作用。代之而行
// Setup to be able to record global sounds (preexisting app sounds)
NSError *sessionError = nil;
if ([[AVAudioSession sharedInstance] respondsToSelector:@selector(setCategory:withOptions:error:)])
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDuckOthers error:&sessionError];
else
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&sessionError];
// Set the audio session to be active
[[AVAudioSession sharedInstance] setActive:YES error:&sessionError];
//then call your asset writer
movieWriter = [[AVAssetWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)];https://stackoverflow.com/questions/6803337
复制相似问题