我已经尝试过 GPUImage 库中的示例。我尝试了“SimpleVideoFileFilter”,但我看到的都是带有滑块的黑屏。我试着自己做同样的事情,我得到了完美的图像。但我无法真正理解视频过程。从项目本身获取视频的示例?来自mac的文件夹?还是来自 iPhone 的视频?我没有 Apple Developer 帐户,因此无法在我的设备上进行真正的测试。我找到了将随机 (.m4v) 文件放入 iPhone 模拟器的方法,并尝试播放/过滤视频。
有人有这个问题吗?我现在正在尝试播放 iPhone 模拟器中的视频或资源文件.. 我真的不知道它是如何工作的。我试过这个链接,没有运气。
这是我们可以在 GPUImage 中找到的示例的一部分:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"sample_iPod" withExtension:@"m4v"];
movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
movieFile.runBenchmark = YES;
movieFile.playAtActualSpeed = YES;
filter = [[GPUImagePixellateFilter alloc] init];
// filter = [[GPUImageUnsharpMaskFilter alloc] init];
[movieFile addTarget:filter];
// Only rotate the video for display, leave orientation the same for recording
GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];
// In addition to displaying to the screen, write out a processed version of the movie to disk
NSString *pathToMovie = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/TestMovie.m4v"];
unlink([pathToMovie UTF8String]); // If a file already exists, AVAssetWriter won't let you record new frames, so delete the old movie
NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(640.0, 480.0)];
[filter addTarget:movieWriter];
// Configure this for video from the movie file, where we want to preserve all video frames and audio samples
movieWriter.shouldPassthroughAudio = YES;
movieFile.audioEncodingTarget = movieWriter;
[movieFile enableSynchronizedEncodingUsingMovieWriter:movieWriter];
[movieWriter startRecording];
[movieFile startProcessing];
[movieWriter setCompletionBlock:^{
[filter removeTarget:movieWriter];
[movieWriter finishRecording];
}];
}
应该过滤视频的简单代码..我从那里得到的只是带有滑块的黑屏..
我说的是这个项目。