I am attempting to display a video file with transparency inside my application using a transparency key (RGB: 0x00FF00
, or full green) using @BradLarson's awesome GPUImage toolkit. However, I am experiencing some difficulties with the GPUImageChromaKeyFilter
filter, and I don't quite understand why.
My source video file is available in my dropbox here (12 KB, 3 seconds long, full green background, just a square on the screen),
And I used the sample project titled SimpleVideoFilter
.
This is the code I attempted to use (I simply replaced -viewDidLoad
):
NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"sample" withExtension:@"m4v"];
movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
filter = [[GPUImageChromaKeyFilter alloc] init];
[filter setColorToReplaceRed:0 green:1 blue:0];
[filter setEnabled:YES];
[movieFile addTarget:filter];
GPUImageView *filterView = (GPUImageView *)self.view;
[filter addTarget:filterView];
[movieFile startProcessing];
According to the documentation (which is sparse), this should have the effect of replacing all of the green in the video. Instead, I get this as an output:
Which tells me that the video is playing (and thus it's copying to the application), but it doesn't seem to be doing any chroma keying. Why would this be? Do I need to manually set smoothing values & thresholds? I shouldn't, because the source only contains two colors (0x00FF00
and 0x000000
).
I have tested this on the device as well, to no avail. Almost all other filters I attempt to use work, such as GPUImageRGBFilter
, GPUImageSepiaFilter
, etc. Could GPUImageChromaKeyFilter
just be broken?
Any help with this would be appreciated, as at this point I'm scraping the bottom of the barrel for transparency on a video.