gpt4 book ai didi

ios - 无法使用 GPUImage 编辑视频

转载 作者:行者123 更新时间:2023-12-01 18:52:48 25 4
gpt4 key购买 nike

我已经使用 AVFoundation 创建了视频,现在我想通过 GPUImage 框架对其进行编辑。我已经按照提及设置了所有设置 here .在看到他的“SimpleVideoFileFilter”示例后,我刚刚复制了他的代码并将我的 Assets URL 替换为视频。这是代码。

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

但我收到以下错误。 error in GPUImage请帮我解决这个问题。

最佳答案

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

为了解决这个错误,我刚刚替换了

movieFile.audioEncodingTarget = movieWriter;


movieFile.audioEncodingTarget = nil;

并且代码工作正常。

关于ios - 无法使用 GPUImage 编辑视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29917481/

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