我正在尝试使视频过滤工作 [英] I'm trying to get the video filtering working

查看:95
本文介绍了我正在尝试使视频过滤工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了GPUImage库中的示例. 我尝试了"SimpleVideoFileFilter",但所有看到的都是带有滑块的黑屏. 我自己尝试做同样的事情,使图像完美工作. 但我无法真正理解视频过程. 从项目本身获取视频的示例?从Mac的文件夹?还是来自iPhone的视频? 我没有Apple Developer帐户,因此无法在我的设备上进行实际测试. 我找到了在iPhone模拟器中放置随机(.m4v)文件的方法,并尝试播放/过滤视频.

I've tried the examples from the GPUImage library. I tried the 'SimpleVideoFileFilter' but all I see its black screen with the slider. I tried to do the same by my self, I got the images working perfect. but I can't really understand the videos process. the examples taking the videos from the project itself ? folder from the mac ? or its from the iPhone's videos ? I don't have Apple Developer account, so I can't really test it on my device. I found way to put an random (.m4v) file in the iPhone Simulator, and tried to play/filter the video.

有人遇到过这个问题吗?我现在只想播放来自iPhone Simulator或资源文件中的视频..我真的不知道它在哪里工作. 我尝试了链接,没有运气.

anyone had this issue ? I'm trying for now just to play the video from the iPhone Simulator or the resource files .. I don't really know where how its works. I tried this link, no luck.

这是我们可以在GPUImage中找到的示例的一部分:

Here is part of the example that we can find in 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];
    }];
}

应该过滤视频的简单代码.. 我从那里得到的就是带有滑块的黑屏..

simple code that should filter the video .. all I get from there is black screen with the slider ..

我正在谈论这个项目.

推荐答案

使用GPUImage在模拟器中当前无法播放电影.您需要在实际设备上运行此程序才能执行此工作.

Movie playback does not currently work within the Simulator using GPUImage. You'll need to run this on an actual device to have this work.

我不确定为什么从模拟器运行时电影文件为什么不输出任何内容,但是欢迎您深入研究GPUImageMovie代码,看看有什么问题.由于它在实际硬件上运行时运行良好,因此修复它并不是我的首要任务.

I'm not sure why movie files don't output anything when run from the Simulator, but you're welcome to dig into the GPUImageMovie code and see what might be wrong. Since it runs fine when operated on actual hardware, it hasn't been a priority of mine to fix.

这篇关于我正在尝试使视频过滤工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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