无法使用GPUImage编辑视频 [英] Unable to edit video using GPUImage

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

问题描述

我已经使用AVFoundation创建了视频,现在我想通过GPUImage框架对其进行编辑.
我已经按照提及的内容设置了所有设置此处.看完他的"SimpleVideoFileFilter"示例后,我刚刚复制了他的代码并替换了我的视频资源URL.这是代码.

I have created video using AVFoundation and now I want to edit it via GPUImage framework.
I have set all the setting as per mention here. After seeing his example of "SimpleVideoFileFilter" I have just copied his code and replace my Assets URL for Video. Here is the code.

movieFile = [[GPUImageMovie alloc] initWithURL:player.contentURL];
pixellateFilter = [[GPUImagePixellateFilter alloc] init];

[movieFile 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.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];

[movieWriter startRecording];
[movieFile startProcessing];

NSLog(@"precess started");
[movieWriter setCompletionBlock:^{
    [pixellateFilter removeTarget:movieWriter];
    [movieWriter finishRecording];
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"completed");
    });
}];

但是我遇到以下错误.



请帮我解决这个问题.

But I'm getting following error.



Please help me to solve this issue.

推荐答案

通过阅读我知道当视频没有音频时会发生此错误.
我有同样的问题.我的资产(视频)没有音频.所以面对这个错误.

By reading this I knew that this error occur when video has no audio.
Same issue I have. I have no Audio my asset(Video). So facing this error.

要解决此错误,我只是从

To solve this error I just replaced from

movieFile.audioEncodingTarget = movieWriter;

movieFile.audioEncodingTarget = nil;

并且代码工作正常.

这篇关于无法使用GPUImage编辑视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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