2

我想对视频实现模糊效果。要播放视频,我使用 MPMoviePlayerViewController。但是,我不知道如何为电影实现模糊效果。我试图在电影上方叠加模糊图像以实现模糊效果,但这是不可能的。视频播放时,应实时变化。我找到了实现图像模糊效果的库,但找不到实时将模糊效果应用于视频的库。我使用 mp4 文件来实现模糊效果。我尝试使用 GPUImage 框架,但它不能完全运行。怎么能实现呢?请帮我。谢谢。

在此处输入图像描述

4

1 回答 1

1

我相信 Brad Larson 的 GPUImage 是最好的实现方式。

以下是GPUImage的github页面的摘录

//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];

由于 GPUImage 有开源代码,您可以打开GPUImageVideoCamera该类并研究它执行视频数据实时过滤的部分。然后使用 Apple 的CoreVideo框架来抓取正在播放的电影视频的视频数据,并让这个 GPUImage 部分为它工作。

有时,样板代码不可用,但总有出路……祝你好运。:)

于 2013-08-02T12:17:43.017 回答