6

I am currently working on HTTP Live streaming video with AVPlayerViewController / AVPlayer

I am playing a video with .m3u8 file supported

It is playing fine but my question is that can I have the data of video like I have to set 4 types of resolution while generating the .m3u8 file.. , I can varies the resolution at my end point now the question is how to get the all values which i have setup at my endpoint. I am play this is in android also and using Track i am able to fetch all the video information but in ios how can i fetch all the details containing the video like its height , with, track,resolution supported by video etc..

I have search a lot but could not get succeed.. Need help Thanks in advance

    #EXTM3U

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="audio/stereo/en/128kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="stereo",LANGUAGE="dubbing",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,URI="audio/stereo/none/128kbit.m3u8"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="audio/surround/en/320kbit.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="surround",LANGUAGE="dubbing",NAME="Dubbing",DEFAULT=NO,AUTOSELECT=YES,URI="audio/stereo/none/128kbit.m3u8"

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Deutsch",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="de",URI="subtitles_de.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",URI="subtitles_en.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Espanol",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="es",URI="subtitles_es.m3u8"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Français",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="fr",URI="subtitles_fr.m3u8"

#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=258157,CODECS="avc1.4d400d,mp4a.40.2",AUDIO="stereo",RESOLUTION=422x180,SUBTITLES="subs"
video/250kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=520929,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="stereo",RESOLUTION=638x272,SUBTITLES="subs"
video/500kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=831270,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="stereo",RESOLUTION=638x272,SUBTITLES="subs"
video/800kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1144430,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="surround",RESOLUTION=958x408,SUBTITLES="subs"
video/1100kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1558322,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="surround",RESOLUTION=1277x554,SUBTITLES="subs"
video/1500kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4149264,CODECS="avc1.4d4028,mp4a.40.2",AUDIO="surround",RESOLUTION=1921x818,SUBTITLES="subs"
video/4000kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=6214307,CODECS="avc1.4d4028,mp4a.40.2",AUDIO="surround",RESOLUTION=1921x818,SUBTITLES="subs"
video/6000kbit.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=10285391,CODECS="avc1.4d4033,mp4a.40.2",AUDIO="surround",RESOLUTION=4096x1744,SUBTITLES="subs"
video/10000kbit.m3u8
Uma Sankar Buddi
  • 277
  • 2
  • 14
Divyesh Gondaliya
  • 884
  • 11
  • 21

2 Answers2

0
var urlData: Data!
var savedString: String!

urlString = "https://xcxc.xxxxx.app/mobile/test.m3u8"

if let url = URL(string: urlString) {
                 urlData = try Data(contentsOf: url)
                 savedString = String(data: urlData, encoding: .utf8)
}
Achsum
  • 133
  • 1
  • 8
-2

Yes, You can get the natural size of the video, if it is playing in the player. As you said that you're playing the URL in AVPlayer then use the following code to get the natural size of the playing track.

if let track = self.tampPlayer?.currentItem?.tracks.first {
        print("Size = \(track.assetTrack.naturalSize)")
}

No matter whatever the url is, if it's playing in player there will be the size for video defiantly.

bestiosdeveloper
  • 2,339
  • 1
  • 11
  • 28
  • i am talking about the resolution size....how can i get that....i have to create like quality list and change based on selected resolution like you tube.....have you any solution for that ????? – Divyesh Gondaliya Jun 14 '17 at 06:05
  • i tray your code but its return me ~ DemoVideo.MediaPlaylist – Divyesh Gondaliya Jun 14 '17 at 06:06
  • 1
    To change the video quality, you've to create different urls for each bitrate like 144, 320, 480, 640, 720, 1080 etc. And have it on the player screen, whenever the user will change the bitrate you've to reload the player item with the url related to selected bitrate. – bestiosdeveloper Jun 14 '17 at 06:18
  • to change quality i have to set some list like 320,480,720 how to get this from url that is my point dear.....have some idea ??? – Divyesh Gondaliya Jun 14 '17 at 06:29
  • whoever is creating the urls for different bitrates your backend partner or any third party. They will provide you the different urls to their respective bitrates. – bestiosdeveloper Jun 14 '17 at 07:43