Requesting HLS video url from KALTURA

Hi,

I am uploading videos to KALTURA server and streaming them on my device.
How do I request “hls” urls for videos ? I am using php to connect to KALTURA.

Any help is appreciated.
Thanks

1 Like

Hello @karanveer_sharma ,

Starting with version 2.48 of the Kaltura HTML5 player, HLS is the default playback method and so, going to KMC->Studio and creating a new player [or making sure your existing players are upgraded to the latest version] will result with a player that uses HLS for playback.

When playing a video, you can easily see the playback method used and the full playManifest request by starting a HTTP sniffer [you can use your browser’s dev tools and look at the requests listed in the “Network” tab], a HLS manifest request looks like this:
https://cdnapisec.kaltura.com/p/$PARTNER_ID/sp/$PARNER_ID00/playManifest/entryId/$ENTRY_ID/flavorIds/$LIST_OF_FLAVOUR_IDs/format/applehttp/protocol/https/a.m3u8

To embed a player, go to KMC->Content->YOUR ENTRY->Actions select box->Preview & Embed

From there, you will be able to select your desired player and copy the HTML and JS code you need to place on the page you’d like to load the player to.

Thanks @jess , I got the hls url.
I have one more doubt though.
Could you explain to me about adaptive streaming using Kaltura.
How do I support multiple qualities of same video using Kaltura ?
Do I have to use encoder at my web-server to provide multiple bitrate of videos to Kaltura, if yes how could I do it and how Kaltura manages the manifest file ?
Do Kaltura have inbuilt encoder which could do this on time of uploading ?

Your help is greatly appreciated.
Thanks

Hello @karanveer_sharma,

Here is a general explanation as to how things work:
A source video is transcoded into various flavours grouped under a conversion profile. The transcoding is done by a mechanism called KDL [Kaltura Decision Layer], which is part of our server code base, which you can browse here: https://github.com/kaltura/server

The transcoding is done mainly by ffmpeg, although we also make use of mencoder in certain situations.

Each such conversion profile can include one or more flavours, optimised for different bandwidth conditions and devices.
A certain partner can have one or more such profiles, if more than one profile exist, you can specify the desired profile when uploading an entry [using KMC or the API directly].

We have a default set of flavours that comprises the default conversion profile and each partner gets these set up when the account is created.
You can then use the KMC to disable some flavours and adjust some basic attributes.
This can be done from ‘Settings’->‘Transcoding settings’

In order to modify more advanced settings in each flavour, API calls need to be made. Using the API, you can also define additional flavours, on top of the default ones each partner is set up with.

You can read a bit more on that here:

Needless to say, setting up flavours requires a lot of expertise and knowledge, in video formats in general and the inner workings of ffmpeg [the main tool used by Kaltura to perform the transcoding] in particular.

As for the playback side of things, the Kaltura player supports HLS, HDS and DASH [all of which make use of adaptive bitrate mechanisms] and the default playback method is HLS.
The player makes an API request to server to get the manifest which looks like this:

http://$HOST/p/$PARTNER_ID/sp/$PARTNER_ID00/playManifest/entryId/$ENTRY_ID/flavorIds/$FLAV0,$FLAV1,$FLAV2,$FLAV3/format/applehttp/protocol/http/a.m3u8?....

for instance:

http://jessex/p/102/sp/10200/playManifest/entryId/0_22bqymiq/flavorIds/0_uqs3qqh6,0_e0lgehpv,0_ip2l71zy,0_04kzo9dh/format/applehttp/protocol/http/a.m3u8

which will result in the following manifest being returned:

({"entryId":"0_22bqymiq","duration":1303,"baseUrl":"","flavors":[
{"url":"http:\/\/jessex:88\/hls\/p\/102\/sp\/10200\/serveFlavor\/entryId\/0_22bqymiq\/v\/2\/flavorId\/0_uqs3qqh6\/name\/a.mp4\/index.m3u8","ext":"mp4","bitrate":468,"width":640,"height":480,"audioLanguage":null,"audioLanguageName":null,"audioLabel":null},
{"url":"http:\/\/jessex:88\/hls\/p\/102\/sp\/10200\/serveFlavor\/entryId\/0_22bqymiq\/v\/2\/flavorId\/0_e0lgehpv\/name\/a.mp4\/index.m3u8","ext":"mp4","bitrate":666,"width":640,"height":480,"audioLanguage":null,"audioLanguageName":null,"audioLabel":null},
{"url":"http:\/\/jessex:88\/hls\/p\/102\/sp\/10200\/serveFlavor\/entryId\/0_22bqymiq\/v\/2\/flavorId\/0_ip2l71zy\/name\/a.mp4\/index.m3u8","ext":"mp4","bitrate":964,"width":640,"height":480,"audioLanguage":null,"audioLanguageName":null,"audioLabel":null},
{"url":"http:\/\/jessex:88\/hls\/p\/102\/sp\/10200\/serveFlavor\/entryId\/0_22bqymiq\/v\/2\/flavorId\/0_04kzo9dh\/name\/a.mp4\/index.m3u8","ext":"mp4","bitrate":1383,"width":960,"height":720,"audioLanguage":null,"audioLanguageName":null,"audioLabel":null}
]})

As you can see, in this example, the entry was transcoded into 4 different flavours, each with a different bitrate and the player will toggle these based on the bandwidth available.

Hi Jess,
in my case (KalturaCE 14.18) the selector of flavor always only show one flavor although the video contains more.

I detected some things when I request entry for HLS:

The browsers Firefox, Explorer or Edge request 2 requests m3u8 (in the case of Chrome requests 3) of which the first request contains the parameters “&responseFormat=jsonp” and “&callback=jQueryXXX_YYY& _=ZZZ” and as
I think that the JSONP does not return correctly, it asks for the same request again but without the parameters and the result is a playlist.m3u8 with only the information of a single flavor.

For instance, If I use Firefox I can see the following JSONP error:

I have verified that if I modify the parameter “&responseFormat=json” if it correctly returns the XML:

Also the last data of the parameter “&callback=XXX_YYY&_=ZZZ” should be “&callback=XXX_YYY_ZZZ” so that the browser does not think it is another different parameter

Hi @angober,

Please post the invalid JSON so that we can understand what makes it invalid and why…

Thanks,

I use delivery profile type “LOCAL_PATH_APPLE_HTTP” with stream_type “APPLE_HTTP”.

When I push play over video the firt request (m3u8):
https://videos.canal-dsa.gva.es/p/136/sp/13600/playManifest/entryId/0_m6lgqh9l/flavorIds/0_vkpuhnbk,0_v54m2rwx,0_uxesz3yg,0_t6eja5ji/format/applehttp/protocol/https/a.m3u8?referrer=aHR0cHM6Ly92aWRlb3MuY2FuYWwtZHNhLmd2YS5lcw==&ks=ZDdhNTJjMGQwOTA2NzE4NjhmZDhjMmUyOWFlZjc0OTAwMzJiY2E3YXwxMzY7MTM2OzE1NjE3ND
g0MzM7MjsxNTYxNjYyMDMzLjk2OTk7Y2FuYWxndmFAZ3ZhLmVzOyosZGlzYWJsZWVudGl0bGVtZW5Ozs&playSessionId=65bc39bc-73e5-c6fb-0529-7635323621b8&clientTag=html5:v2.75.1&uiConfId=23449452&responseFormat=jsonp&callback=jQuery111105673195228572949_1561662043102&_=1561662043103

Response JSONP (Include all flavors):


jQuery111105673195228572949_1561662043102({“entryId”:“0_m6lgqh9l”,“duration”:98,“baseUrl”:"",“flavors”:[{“url”:“https://streaming.canal-dsa.gva.es/kVOD/content/entry/data/0/1/0_m6lgqh9l_0_vkpuhnbk_2.mp4/playlist.m3u8",“ext”:“mp4”,“bitrate”:961,“width”:640,“height”:360,“audioLanguage”:null,“audioLanguageName”:null,“audioLabel”:null,“audioCodec”:null,“defaultAudio”:false,“frameRate”:25},{“url”:“https://streaming.canal-dsa.gva.es/kVOD/content/entry/data/0/1/0_m6lgqh9l_0_v54m2rwx_2.mp4/playlist.m3u8”,“ext”:“mp4”,“bitrate”:1170,“width”:640,“height”:360,“audioLanguage”:null,“audioLanguageName”:null,“audioLabel”:null,“audioCodec”:null,“defaultAudio”:false,“frameRate”:25},{“url”:“https://streaming.canal-dsa.gva.es/kVOD/content/entry/data/0/1/0_m6lgqh9l_0_uxesz3yg_2.mp4/playlist.m3u8”,“ext”:“mp4”,“bitrate”:1395,“width”:640,“height”:360,“audioLanguage”:null,“audioLanguageName”:null,“audioLabel”:null,“audioCodec”:null,“defaultAudio”:false,“frameRate”:25},{“url”:“https://streaming.canal-dsa.gva.es/kVOD/content/entry/data/0/1/0_m6lgqh9l_0_t6eja5ji_2.mp4/playlist.m3u8”,“ext”:“mp4”,“bitrate”:2154,“width”:640,“height”:360,“audioLanguage”:null,“audioLanguageName”:null,“audioLabel”:null,“audioCodec”:null,“defaultAudio”:false,"frameRate”:25}]})

but the second request (m3u8) not include JSONP:
https://videos.canal-dsa.gva.es/p/136/sp/13600/playManifest/entryId/0_m6lgqh9l/flavorIds/0_vkpuhnbk,0_v54m2rwx,0_uxesz3yg,0_t6eja5ji/format/applehttp/protocol/https/a.m3u8?referrer=aHR0cHM6Ly92aWRlb3MuY2FuYWwtZHNhLmd2YS5lcw==&ks=ZDdhNTJjMGQwOTA2NzE4NjhmZDhjMmUyOWFlZjc0OTAwMzJiY2E3YXwxMzY7MTM2OzE1NjE3NDg0MzM7MjsxNTYxNjYyMDMzLjk2OTk7Y2FuYWxndmFAZ3ZhLmVzOyosZGlzYWJsZWVudGl0bGVtZW50Ozs&playSessionId=65bc39bc-73e5-c6fb-0529-7635323621b8&clientTag=html5:v2.75.1&uiConfId=23449452

and response equal nothing:

How this second m3u8 not include info of flavor (#EXTM3U…) the third request is a playlist.m3u8 where only contain one flavor:


#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1054836,CODECS=“avc1.77.31,mp4a.40.2”,RESOLUTION=640x360
https://streaming.canal-dsa.gva.es/kVOD/content/entry/data/0/1/0_m6lgqh9l_0_vkpuhnbk_2.mp4/chunklist_w1040619006.m3u8

And the result is a entry with only one flavor in selector:

I found my problem over the second request (m3u8) not include response :

As I am using the delivery profile “LOCAL_PATH_APPLE_HTTP” I have modified the file DeliveryProfileLocalPathAppleHttp.php by replacing “kRedirectManifestRenderer” with “kM3U8ManifestRenderer” (it also works if I delete the function function __construct) and so that Wowza also has the multiflavor by replace /playlist.m3u8 by /chunklist.m3u8:

me too…
Thanks