我的项目中的GPUImageView集成

时间:2013-04-29 10:01:58

标签: xcode4.5 gpuimage ios6.1

我想做的就是这个。

- (void)viewDidLoad
{
    [super viewDidLoad];


    NSURL *url2 = [[NSBundle mainBundle] URLForResource:@"NAN" withExtension:@"mov"];
    GPUImageMovie *movie2 = [[GPUImageMovie alloc] initWithURL:url2];

    movie2.playAtActualSpeed = YES;

    filter0 = [[GPUImageSepiaFilter alloc] init];

    [movie2 addTarget:filter0];
    [filter0 addTarget:view0]; // view0 is a GPUImageView taken in nib

    [self recordVideo];
    isRecording = YES;

    [movie2 startProcessing];

    [movieWriter setCompletionBlock:^{
        if (isRecording) {
            [self stopRecording];
            isRecording = NO;
        }    }];

}


-(void)recordVideo {
    NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"file.mov"];
    NSURL *url = [NSURL fileURLWithPath:path];

    NSFileManager *fm = [NSFileManager defaultManager];
    [fm removeItemAtPath:path error:nil];

    movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:url size:CGSizeMake(640, 480)];
    [filter0 addTarget:movieWriter];
    [movieWriter startRecording];
}


-(void)stopRecording {
    [movieWriter finishRecording];
}

但这根本不起作用。我总是用这段代码获得黑色视频。没有崩溃,我得到的黑色视频与原始视频的持续时间相同。有没有人遇到过同样的问题。请帮助。

任何帮助都会很棒。

0 个答案:

没有答案