BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.23k stars 4.61k forks source link

GPUImageRawDataOutput occasionally output wrong frame #2309

Open dwfangyang opened 8 years ago

dwfangyang commented 8 years ago

I start a filter chain with a GPUImageTextureInput, and end the chain with a GPUImageRawDataOutput output, but occasionally on iPhone 5s,6,6P, the GPUImageRawDataOutput output wrong frame looks like the intermediate frame somewhere in the filter chain, and my code looks like this:

[GPUImageContext useImageProcessingContext]; GPUImageTextureInput input = [[GPUImageTextureInput alloc] initWithTexture:rgbTexture size:size]; GPUImageFilter beautyFilter = [GPUImageBeautyFilter new]; [input addTarget:beautyFilter]; GPUImageView view = [GPUImageView new]; [beautyFilter addTarget:view]; GPUImagePicture* pic =[ [GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"abc"]]; GPUImageTwoInputFilter* watermarkFilter = [GPUImageWaterMarkFilter new]; [filter addTarget:watermarkFilter atTextureLocation:0]; [pic addTarget:watermarkFilter atTextureLocation:1]; [pic processImage]; GPUImageRawDataOutput* rawDataOutput = [[GPUImageRawDataOutput alloc] initWithImageSize:size resultsInBGRAFormat:YES]; [watermarkFilter addTarget:rawDataOutput];

the pixelbuffer I get from the rawDataOuput's newFrameAvailableBlock is right, with the watermark picture within it ,but occasionally, the pixelbuffer is wrong with no watermark within it ,and makes it look like the output of the beautyFilter and I don't know why. Could you please tell me where is wrong?

nightwolf-chen commented 7 years ago

I've came across similar problem, it was caused by multiple instances of video capture session. You should check out whether there are some memory leaks and multiple instances of capture session.

dwfangyang commented 7 years ago

well, it seems like I use the output pixelbuffer at another thread which does not belong to the gpuimagecontextqueue, after I move the operation back to the gpuimagecontextqueue, everything is fine