I believe GPUImage from Brad Larson is the best way to achieve.
Following is the excerpt from the github page of GPUImage
//Filtering live video
//To filter live video from an iOS device's camera, you can use code like the following:
GPUImageVideoCamera *videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
videoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
GPUImageFilter *customFilter = [[GPUImageFilter alloc] initWithFragmentShaderFromFile:@"CustomShader"];
GPUImageView *filteredVideoView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, viewWidth, viewHeight)];
// Add the view somewhere so it's visible
[videoCamera addTarget:customFilter];
[customFilter addTarget:filteredVideoView];
[videoCamera startCameraCapture];
Since GPUImage has open-source code, you can open up the GPUImageVideoCamera
class and study the portion where it perform the live filtering of video data. Then use Apple's CoreVideo
framework to grab the video data of a movie video being played and make this GPUImage portion work for it.
Sometimes, boiler-plate codes are not available, but there's always a way out.. Good luck. :)