我可以用GPUImage在视频上设置框架吗?

时间:2012-07-06 12:00:51

标签: iphone objective-c avfoundation video-processing gpuimage

我有一个本地视频文件,现在我已经在GPUImage库的帮助下应用了过滤器, 这里是使用GPUImage制作过滤视频的代码

movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
pixellateFilter = [[GPUImagePixellateFilter alloc] init];
GPUImageRotationFilter *rotationFilter = [[GPUImageRotationFilter alloc] initWithRotation:kGPUImageRotateRight];

[movieFile addTarget:rotationFilter];
[rotationFilter addTarget:pixellateFilter];

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

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

[movieWriter startRecording];
[movieFile startProcessing];

[pixellateFilter removeTarget:movieWriter];
[movieWriter finishRecording];

现在我想在这个视频文件上应用框架,我的意思是我已经获取了视频文件的naturalSize。并希望在此视频文件中应用带有naturalSize的框架。

我该怎么办?有可能吗?

此致

********解决了********* 根据我的限制在视频上添加GPUI图像无法实现的图像。 非常感谢link

1 个答案:

答案 0 :(得分:0)

是的,您可以按照@ mayur-shrivas的代码获取自然大小的视频文件 根据{{​​3}}

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