iOS - How to play a video with transparency?

前端 未结 8 1338
情书的邮戳
情书的邮戳 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:17

    You'll need to build a custom player using AVFoundation.framework and then use a video with alpha channel. The AVFoundation framework allows much more robust handeling of video without many of the limitations of MPMedia framework. Building a custom player isn't as hard as people make it out to be. I've written a tutorial on it here: http://www.sdkboy.com/?p=66

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题