Question

I want to implement blur effect to Video. To play video, I use MPMoviePlayerViewController. But, I don't know how to implement blur effect to movie. I tried to overlay blur image above the movie so implement blur effect, but it isn't possible. When video play, It should change with real time. I found libraries to implement image blurr effect, but can't find library to apply blur effect to video with realtime.I use mp4 file for blur effect. I tried to use GPUImage framework, but it doesn't run exactly. How can implement that? Please help me. Thanks.

enter image description here

Was it helpful?

Solution

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. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top