создать видео эффект от GPUImage как этотGPUImageMovie не поддерживает альфа-канал?
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;
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];
[maskMovie addTarget:filter0];
[alphaMovie addTarget:filter0];
[filter0 addTarget:filter1];
[topMovie addTarget:filter1];
[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];
});
});
код может работать и я получил видео эффект, как этот
видео имеет черный фон, который является потому, что alphaMovie не играть в то же время с маскойМови?
Это то, что я хочу, чтобы создать
Эффект видео не черный фон
Вопрос:
1: Как я могу удалить черный фон?
2: Почему у меня видео эффекта на черном фоне?
@Brad Larson Пожалуйста, помогите мне .. – Allan