GPUImageMovieWriter黑屏问题

来源:互联网 发布:微霸科技软件 编辑:程序博客网 时间:2024/05/17 03:32

使用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

    }**

原创粉丝点击