使用GPUImage录制视频时第一帧会出现黑屏或者白屏,并且调用addAudioInputsAndOutputs也不好使
此时需要修改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
...
}