关于使用GPUImage拍摄视频第一帧黑屏
2018-10-17 本文已影响0人
Insit
解决一:
//该句允许声音的情况下,避免录制闪屏
[_camera 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
...
}
思考:黑屏的原因?
答:音频缓冲区是在视频缓冲区之前写入的。