Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing H.265 video file using AVPlayer

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?

like image 570
Bharath Reddy Avatar asked Mar 06 '18 10:03

Bharath Reddy


People also ask

Can iPhone play H265?

Since September 19, all iPhone 7 and up (and 2017 iPad Pros) can now fully deliver and receive video in the H. 265 codec - a step up from H. 264 that has been used since the very first iPhone was released.

Can iPhone play MP4 H265?

Yes. Since Apple released iOS 11 in 2017, HEVC codec is fully supported by newer iPhones.

What does HEVC mean on iPhone?

iOS 11 and macOS High Sierra introduced support for these new, industry-standard media formats: HEIF (High Efficiency Image File Format) for photos. HEVC (High Efficiency Video Coding), also known as H.


1 Answers

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

like image 118
szatmary Avatar answered Oct 04 '22 08:10

szatmary