I have a video with a solid green background, that I am trying to make transparent with GPUImageChromaKeyFilter.
When I have clear colour for the player view, the result is that the video is not really transparent, but tints the background:
When I change the background to white, the green background is gone, but obviously the view is not transparent:
What am I doing wrong?
My code is:
let movie = GPUImageMovie(URL: url)
let filter = GPUImageChromaKeyFilter()
filter.setColorToReplaceRed(0, green: 1, blue: 0)
movie.addTarget(filter)
let playerView = GPUImageView()
playerView.backgroundColor = UIColor.clearColor()
playerView.setBackgroundColorRed(0, green: 0, blue: 0, alpha: 0)
let trinity = (movieFile, filter, playerView)
filter.addTarget(playerView)
movie.startProcessing()
I am storing the movie, filter and view to avoid ARC releasing them when scope is exited and I add the view to the correct superview and position it with auto layout.
The video I am using is an h264 video - https://dl.dropboxusercontent.com/u/1400954/Coin.mp4
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…