iosavplayeravplayerlayerm4v

Cannot play transparent video in iOS AVPlayer, what can I do?


I need to remove green background from the video so that it looks transparent and content behind it can be visible. Following is a sample of a video, I am attaching screenshot of it.

enter image description here

I have tried VideoTransparentBackground library, and I achieved it, but issue is while I put App in background and come back, it renders black background and I found this is not stable solution.

What can I do else? Any hint?


Solution

  • Your video needs to encoded with an Alpha Channel. ProRes 4444 will do that, as well as the recent HEVC format. Also remember, the transparent area will have the colour of your window or view area. If you put your clip into an AVPlayerView, it will have a black BG. Essentially, if you don't encode your alpha channel into the video, as per your example, you would need to use a CIImage filter to do live "Green Screening" which will require a load more processing power.