gpt4 book ai didi

ios - GPUImage : Apply filer to existing video file

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:42:28 29 4
gpt4 key购买 nike

我正在尝试使用 GPUImage 框架的视频过滤器。我关注了Filtering and re-encoding a movie教程。它给我错误 Unknown type name GPUImageRotationFilter。所以我尝试对我的视频文件应用一个简单的过滤器

这是我的代码
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

堆栈跟踪

enter image description here

  1. 我做错了什么?
  2. 可以向我解释如何将 GPUImage 过滤器应用于现有视频文件吗?

最佳答案

首先用最新的更新你的 GPUImageFramework。您可以从 here 获得新的.

仔细检查 moviewWriter 的大小。它应该是 CGSizeMake(640.0, 480.0) 而不是 CGSizeMake(480.0, 640.0)

或者您可以创建视频 Assets ,然后在大小参数中提供视频 Assets 的大小。

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

它对我有用。

关于ios - GPUImage : Apply filer to existing video file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16332390/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com