Playing H.265 video file using AVPlayer
Asked Answered
P

1

6

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?

Podvin answered 6/3, 2018 at 10:1 Comment(0)
S
15

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

Sulla answered 6/3, 2018 at 15:18 Comment(6)
Thanks for the response. I will try and check.Podvin
I created new mp4 with tag changed to hvc1. It is now playing fine in macOS using quick time player but when i added to iOS project it is still not showing video. Do i need to something else?Podvin
It is playing perfectly in iOS 11 device but not playing in iOS 10 device. Can we change something so that it can play even in iOS 10 devices?Podvin
Ios10 does not support hevc.Sulla
The same video file is playing in shareIt app even in iOS 10 device. Do you know how they do it?Podvin
Well thanks Apple for that little landmine. Spent the better part of a day trying to track that down.Chitchat

© 2022 - 2024 — McMap. All rights reserved.