I am trying to play an HEVC(H.265) codec media url on AVPlayer. But the video is not showing. I didn't get any solution. How do I implement this in ios?
let videoURL = URL(string: "http://bitmovin-a.akamaihd.net/content/dataset/multi-codec/hevc/stream_fmp4.m3u8")
let avPlayer = AVPlayer(url: videoURL!)
let playerViewController = AVPlayerViewController()
playerViewController.player = avPlayer
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
Following your example I am able to play this content on a device (not simulator)
Pay attention also that I changed the URL from HTTP to HTTPS!
import UIKit
import AVFoundation
class ViewController: UIViewController {
let videoURL = URL(string: "https://bitmovin-a.akamaihd.net/content/dataset/multi-codec/hevc/stream_fmp4.m3u8")
let avPlayer = AVPlayer()
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
let asset = AVAsset(url: videoURL!)
let playerItem = AVPlayerItem(asset: asset)
avPlayer.replaceCurrentItem(with: playerItem)
let avLayer = AVPlayerLayer(player: avPlayer)
avLayer.frame = view.bounds
view.layer.addSublayer(avLayer)
avPlayer.play()
}
}
NB:
The container format for HEVC video MUST be fMP4.
There are a few ways to deliver HEVC content to users:
For reference: WWDC17 – HEVC with HLS – Apple just announced a feature that we support out of the box