We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is my code, I want to create video effect. But i got black background. GPUImage Not Support Alpha Channel ? Description : "http://stackoverflow.com/questions/34989942/gpuimagemovie-not-support-alpha-channel"
self.overlayerView = [[GPUImageView alloc] init]; self.overlayerView.frame = self.view.frame; dispatch_queue_t queue = dispatch_queue_create("queue", NULL); dispatch_async(queue, ^{ NSURL *sourceURL = [[NSBundle mainBundle] URLForResource:@"212121" withExtension:@"mp4"]; GPUImageMovie *sourceMovie = [[GPUImageMovie alloc] initWithURL:sourceURL]; sourceMovie.playAtActualSpeed = YES; sourceMovie.shouldRepeat = YES; sourceMovie.shouldIgnoreUpdatesToThisTarget = YES; NSURL *maskURL = [[NSBundle mainBundle] URLForResource:@"rose" withExtension:@"mp4"]; GPUImageMovie *maskMovie = [[GPUImageMovie alloc] initWithURL:maskURL]; maskMovie.playAtActualSpeed = YES; maskMovie.shouldRepeat = YES; NSURL *alphaURL = [[NSBundle mainBundle] URLForResource:@"rose_alpha" withExtension:@"mp4"]; GPUImageMovie *alphaMovie = [[GPUImageMovie alloc] initWithURL:alphaURL]; alphaMovie.playAtActualSpeed = YES; alphaMovie.shouldRepeat = YES; NSURL *topURL = [[NSBundle mainBundle] URLForResource:@"screen" withExtension:@"mp4"]; GPUImageMovie *topMovie = [[GPUImageMovie alloc] initWithURL:topURL]; topMovie.playAtActualSpeed = YES; topMovie.shouldRepeat = YES; GPUImageAddBlendFilter *addFilter = [[GPUImageAddBlendFilter alloc] init]; [maskMovie addTarget:addFilter]; [alphaMovie addTarget:addFilter]; filter0 = [[GPUImageThreeInputFilter alloc] initWithFragmentShaderFromString:@"precision highp float;uniform sampler2D inputImageTexture;uniform sampler2D inputImageTexture2;uniform sampler2D inputImageTexture3;varying vec2 textureCoordinate;void main(){vec4 video=texture2D(inputImageTexture,textureCoordinate);vec4 mv=texture2D(inputImageTexture2, textureCoordinate);vec4 alpha = texture2D(inputImageTexture3, textureCoordinate);gl_FragColor = video * (1.0 - alpha.r) + mv;}"]; filter1 = [[GPUImageTwoInputFilter alloc] initWithFragmentShaderFromString:@"\nprecision highp float;\nuniform sampler2D inputImageTexture; //video\nuniform sampler2D inputImageTexture2; //screen\nvarying vec2 textureCoordinate;\nvoid main()\n{\nvec4 video = texture2D(inputImageTexture, textureCoordinate);\nvec4 screen = texture2D(inputImageTexture2, textureCoordinate);\nmediump vec4 whiteColor = vec4(1.0);\ngl_FragColor = whiteColor - ((whiteColor - screen) * (whiteColor - video));\n}"]; [sourceMovie addTarget:filter0 atTextureLocation:0]; [maskMovie addTarget:filter0 atTextureLocation:1]; [alphaMovie addTarget:filter0 atTextureLocation:2]; [filter0 addTarget:filter1 atTextureLocation:0]; [topMovie addTarget:filter1 atTextureLocation:1]; [sourceMovie startProcessing]; [alphaMovie startProcessing]; [maskMovie startProcessing]; [topMovie startProcessing]; [filter0 forceProcessingAtSize:CGSizeMake(480,480)]; [filter1 forceProcessingAtSize:CGSizeMake(480,480)]; dispatch_async(dispatch_get_main_queue(), ^{ [filter1 addTarget:self.overlayerView]; }); });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Here is my code, I want to create video effect. But i got black background.
GPUImage Not Support Alpha Channel ?
Description : "http://stackoverflow.com/questions/34989942/gpuimagemovie-not-support-alpha-channel"
The text was updated successfully, but these errors were encountered: