GPUImage GPUImageTwoInputFilter两个视频

时间:2013-12-18 09:41:33

标签: objective-c gpuimage blending mixing chromakey

我使用GPUImageTwoInputFilter(任何过滤器,如GPUImageChromaKeyBlendFilter)对两个视频的GPUImage有问题。在这种情况下,我没有视频。

@interface ViewController ()

@property (nonatomic) GPUImageMovie *video;
@property (nonatomic) GPUImageMovie *chromaVideo;
@property (nonatomic) GPUImageMovieWriter *movieWriter;
@property (nonatomic) GPUImageColorDodgeBlendFilter *filter;

@end

@implementation ViewController

- (void)viewDidLoad
{
    NSURL *videoUrl = [[NSBundle mainBundle] URLForResource:@"video"
                                         withExtension:@"MOV"];

    _video = [[GPUImageMovie alloc] initWithURL:videoUrl];
    _video.playAtActualSpeed = YES;

    NSURL *chromaVideoUrl = [[NSBundle mainBundle] URLForResource:@"chroma"
                                          withExtension:@"mov"];
    _chromaVideo = [[GPUImageMovie alloc] initWithURL:chromaVideoUrl];
    _chromaVideo.playAtActualSpeed = YES;

    _filter = [[GPUImageColorDodgeBlendFilter alloc] init];
    //[_filter setThresholdSensitivity:0.45];

    [_video addTarget:_filter];
    [_chromaVideo addTarget:_filter];

    NSURL *outURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/MovieMix.mov"]];

    NSFileManager *fm = [NSFileManager defaultManager];
    [fm removeItemAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/MovieMix.mov"]
                   error:nil];

    _movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:outURL size:CGSizeMake(1280, 720)];

    __weak ViewController *weakSelf = self;
    [_filter addTarget:_movieWriter];

    [_movieWriter startRecording];
    [_video startProcessing];
    [_chromaVideo startProcessing];

    [_movieWriter setCompletionBlock:^
     {
         [weakSelf.filter removeTarget:weakSelf.movieWriter];
         [weakSelf.movieWriter finishRecording];
         UISaveVideoAtPathToSavedPhotosAlbum([NSHomeDirectory() stringByAppendingPathComponent:@"Documents/MovieMix.mov"],nil,nil,nil);
         NSLog(@"Done");
     }];
}

但是当我使用dispatch_after 5秒在完成块中进行操作时,我的画廊中有一段持续时间== 0的视频(我认为它有1帧)。

0 个答案:

没有答案