5

I am trying to play H.265 video file using AVPlayer(Both in iOS 10,11). Following is the code:

 let fileUrl = Bundle.main.url(forResource: "sample-h265-360", withExtension: "mp4")
 player = AVPlayer(url: fileUrl!)
 player?.play()

Audio is playing fine but video is not showing(I am using AVPlayerViewController). I have read that H.265 is supported in iOS 11 but the result is same for me(audio playing but video not showing).

I tried to transfer the file and play it using other Apps. It worked fine with ShareIt. Can anyone suggest libraries to play this content? or what in-built music player does shareIt use? Is there any mistake in my code? Was anyone successful in playing H.265 file using AVPlayer?

Shivam Tripathi
  • 1,405
  • 3
  • 19
  • 37
Bharath Reddy
  • 636
  • 1
  • 5
  • 21

1 Answers1

13

For some stupid reason, Apple will only play hevc mp4s that are tagged as ‘hvc1’. Most authoring tools will tag as 'hev1’

You can retag with ffmpeg, but only with very recient builds.

ffmpeg -i input.mp4 -vcodec copy -acodec copy -tag:v hvc1 output.mp4

szatmary
  • 29,969
  • 8
  • 44
  • 57