GPUImage:将文件管理器应用于现有视频文件 [英] GPUImage : Apply filer to existing video file

查看:104
本文介绍了GPUImage:将文件管理器应用于现有视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用GPUImage框架的视频过滤器.我遵循了过滤和重新编码电影的教程.它给我错误Unknown type name GPUImageRotationFilter.因此,我尝试对视频文件应用简单的过滤器

I was trying to use video filters of GPUImage framework. I followed Filtering and re-encoding a movie tutorial. It giving me error Unknown type name GPUImageRotationFilter. So i tried to apply a simple filter to my video file

这是我的代码
viewController.h

Here is my code
viewController.h

@interface ViewController : UIViewController<GPUImageMovieWriterDelegate,GPUImageInput>
{
GPUImageMovie *_movieFile;
GPUImageOutput<GPUImageInput> *_sketchFilter;
GPUImageMovieWriter *_movieWriter;

}
 @property (nonatomic,retain)    GPUImageMovie *movieFile; 
 @property (nonatomic,retain)    GPUImageOutput<GPUImageInput> *sketchFilter; 
 @property (nonatomic,retain)    GPUImageMovieWriter *movieWriter;
@end

viewController.m

NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"sample_iPod" withExtension:@"m4v"];

self.movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
self.sketchFilter = [[GPUImageSketchFilter alloc] init];
[self.movieFile addTarget:self.sketchFilter];


NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie.m4v"];
unlink([pathToMovie UTF8String]);
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];

self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(480.0, 640.0)];
[self.sketchFilter addTarget:self.movieWriter];

[self.movieWriter startRecording];
[self.movieFile startProcessing];

[self.movieWriter setCompletionBlock:^{

    [self.sketchFilter removeTarget:self.movieWriter];
    [self.movieWriter finishRecording];

}];

这也给了我 BAD_ACCESS .

堆栈跟踪

  1. 我做错了什么?
  2. 能给我解释一下如何将GPUImage滤镜应用于现有视频文件吗?

推荐答案

首先用最新的更新您的GPUImageFramework.您可以从此处获取新的

First of all update your GPUImageFramework with the latest one. You can get the new one from here.

再次检查moviewWriter的大小.它应该是CGSizeMake(640.0, 480.0)而不是CGSizeMake(480.0, 640.0).

Double check the size of the moviewWriter. It should be CGSizeMake(640.0, 480.0) instead of CGSizeMake(480.0, 640.0).

或者您可以创建视频资产,然后在size参数中提供视频资产的大小.

Or you can create an video asset and then provide the size of video asset in the size parameter.

AVURLAsset *asset = [AVURLAsset URLAssetWithURLNSURL fileURLWithPath:pathToMovie] options:nil];
AVAssetTrack *videoAssetTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(videoAssetTrack.naturalSize.width, videoAssetTrack.naturalSize.height)];

它为我工作.

这篇关于GPUImage:将文件管理器应用于现有视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆