iOS - How to play a video with transparency?

前端 未结 8 1374
情书的邮戳
情书的邮戳 2020-11-29 06:38

I recorded a video with a bluescreen. We have the software to convert that video to a transparent background. What\'s the best way to play this video overlaid on a custom

8条回答
  •  一整个雨季
    2020-11-29 07:24

    Don't know if anyone is still interested in this besides me, but I'm using GPUImage and the Chromakey filter to achieve this^^ https://github.com/BradLarson/GPUImage

    EDIT: example code of what I did (may be dated now):

    -(void)AnimationGo:(GPUImageView*)view {
        NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mov"];
    
        movieFile = [[GPUImageMovie alloc] initWithURL:url];
        filter = [[GPUImageChromaKeyBlendFilter alloc] init];
    
        [movieFile addTarget:filter];
    
        GPUImageView* imageView = (GPUImageView*)view;
        [imageView setBackgroundColorRed:0.0 green:0.0 blue:0.0 alpha:0.0];
        imageView.layer.opaque = NO;
        [filter addTarget:imageView];
    
        [movieFile startProcessing];
    
        //to loop
        [imageView setCompletionBlock:^{
            [movieFile removeAllTargets];
            [self AnimationGo:view];
        }];
    }
    

    I may have had to modify GPUImage a bit, and it may not work with the latest version of GPUImage but that's what we used

提交回复
热议问题