2

I have the following code which is not working with the mov file, but it works when i use an MP4 file. The important thing about to mov file is because it has an alpha channel. I'm open to find solutions that offers me an alpha channel as mov file does.

class MovViewController: UIViewController {
    var avPlayer: AVPlayer!

    override func viewDidLoad() {
        super.viewDidLoad()
        let filepath: String? = Bundle.main.path(forResource: "animacion_logo", ofType: "mov")
        let fileURL = URL.init(fileURLWithPath: filepath!)


        let player = AVPlayer(url: fileURL)
        let playerLayer = AVPlayerLayer(player: player)
        playerLayer.frame = self.view.bounds
        //        self.view.layer.addSublayer(playerLayer)
        self.view.layer.insertSublayer(playerLayer, at: 0)
        player.play()

    }
}

This is the original mov file: https://ufile.io/jcbfn

Ricardo
  • 7,921
  • 14
  • 64
  • 111

2 Answers2

3

AVPlayer do not support ProRes format with alpha: Using AVPlayer to view transparent video

But there is some options out there. Take a look at this Medium post: https://medium.com/@quentinfasquel/ios-transparent-video-with-coreimage-52cfb2544d54

Semtex
  • 366
  • 3
  • 3
1

You can play H.264 or H.265 (on newer iOS hardware) on iOS, but these formats do not support an alpha channel. There is no built in support for alpha channel, you will need to use a 3rd party library, the other option is a series of PNG images or decoding WebM, but both of these options will consume boat loads of CPU resources.

MoDJ
  • 4,309
  • 2
  • 30
  • 65