Flickering video when using crop.
Hello.
I'm filtering live video, the last chain of filters is a crop. However the video 'flickers' between the cropped (1:1) and non-cropped (16:9) video rapidly. It will then settle to the cropped output for a second or two, then start flickering again. Any ideas why?
Code:
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack]; videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait; filter = [[GPUImageSepiaFilter alloc] init]; crop = [[GPUImageCropFilter alloc] init]; [crop setCropRegion:CGRectMake(0.0, 0.12, 1, 0.75)]; [videoCamera addTarget:filter]; [videoCamera addTarget:crop]; filteredVideoView = [[GPUImageView alloc] initWithFrame:viewBox.frame]; [self.viewBox addSubview:filteredVideoView]; [filter addTarget:filteredVideoView]; [crop addTarget:filteredVideoView]; [videoCamera startCameraCapture]; <code>
Same things happens with latest version I'm afraid.
Oh, I see it now. You don't have your filter chain set up properly. If you want to apply a sepia tone filter, then a crop filter, you need to do them in order. Right now, you have both filters running in parallel and both outputting to the view. This shouldn't work at all, as the view only takes one input, but I think the crop is sometimes overriding the sepia tone on the input.
What you need to do is set the crop as the target of the camera, set the sepia tone as the target of the crop, and then set the view as the target of the sepia tone. That way, you have the proper linear chain.
Ahh, ok, the chains make sense now. Thank you, I can now have a real play.
Is this with the very latest code from the repository? The crop filter was slightly broken, so I repaired part of it last night. If you're not already, try with the latest code.