Video with Gpuimagechromakeyfilter Has Tint When Played in Transparent Gpuimageview

Video with GPUImageChromaKeyFilter has tint when played in transparent GPUImageView?

I got this working. The solution is to use GPUImageChromaKeyBlendFilter.
It blends two sources by replacing the pixels of the colour specified in setColorToReplaceRed in the first source with the pixels in the second source.

So I made a GPUImagePicture with a transparent UIImage and added the filter as a target to it. You can use a transparent PNG or build an UIImage and fill it with transparent in code (empty UIImage won't work!)

Now everything works beautifully!

Working!

The code is

let filter = GPUImageChromaKeyBlendFilter()
filter.setColorToReplaceRed(0, green: 1, blue: 0)

let movieFile = GPUImageMovie(URL: url)
movieFile.addTarget(filter)

let backgroundImage = UIImage(named: "MTransparent")
let sourcePicture = GPUImagePicture(image: backgroundImage, smoothlyScaleOutput: true)
sourcePicture.addTarget(filter)
sourcePicture.processImage()

let playerView = GPUImageView()
playerView.backgroundColor = UIColor.clearColor()
filter.addTarget(playerView)

movieFile.startProcessing()

Play video with transparent background IOS

Here is a link with a real solution to this problem playing-movies-with-an-alpha-channel-on-the-ipad. Her blog post is talking about video on the iPad, but the same library with alpha channel support also works on iPhone. It is also possible to encode to h.264 with alpha channel support using the method described in the blog post comments.

Play video with alpha channel in iOS?

It looks like there's no way to do this with iOS provided solutions. But according to this answer to a similar question you might succeed with ffmpeg. The problem with ffmpeg is that GPL/LGPL are incompatible with Apple's terms so you can't use it in an app for the App Store.

Does getElementById work on elements created by javascript?

To answer your main question: document.getElementById does work with dynamically added elements.

In your sample code you are creating the openMonth div and setting its innerHTML. Then in the remove tag you are doing this:

var month = openMonth.getElementsByTagName("span")[0].innerHTML;

openMonth.getElementsByTagName("span") will not exist and will get an error because there are no span elements. I don't know if this is a mistake in the code or if it is just a incomplete sample in the post.



Related Topics



Leave a reply



Submit