使用GPUImage錄制視頻時(shí)第一幀會(huì)出現(xiàn)黑屏或者白屏,并且調(diào)用addAudioInputsAndOutputs也不好使
此時(shí)需要修改GPUImageMovieWriter.m的源碼,在其中添加以下代碼
static BOOL allowWriteAudio = NO;
- (void)startRecording;
{
...
allowWriteAudio = NO;
}
- (void)processAudioBuffer:(CMSampleBufferRef)audioBuffer;
{
if (!allowWriteAudio) {
return;
}
...
}
- (void)newFrameReadyAtTime:(CMTime)frameTime atIndex:(NSInteger)textureIndex;
{
...
if (![assetWriterPixelBufferInput appendPixelBuffer:pixel_buffer withPresentationTime:frameTime])
NSLog(@"Problem appending pixel buffer at time: %@", CFBridgingRelease(CMTimeCopyDescription(kCFAllocatorDefault, frameTime)));
allowWriteAudio = YES; //< add this
...
}