My web app is based on a payment to rent a video for some days. Now you can pay for 1080p or 4k, if you buy the 1080p version you should see up to 1080p but now you can see the 4k too if your screen supports it. Is there a way to handle this ? If you pay for the 1080p you can see up to 1080p otherwise if you pay for 4k you can see up to 4k.
This is a good question.
So, by default - the HLS manifest will include all versions of the video from 240p to 4k. I have a few options for you - 2 are possible today, one would require a bit of dev work on our side.
-
The “easy” option would be to upload a 1080p version for “all” and a 4k version for paid (but then everything is encoded/hosted 2x.
-
If you want to exclude the 4k video from just one video uploaded, you could re-write the manifest file:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=275000,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=426x240
240/manifest.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=880000,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=640x360
360/manifest.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1540000,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=854x480
480/manifest.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2860000,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=1280x720
720/manifest.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4840000,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=1920x1080
1080/manifest.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=17600000,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=3840x2160
2160/manifest.m3u8
Stripping out the last 2 lines would remove the 4k version from the playable list. The modified manifest would no longer be compatible with the api.video player (you win some… you lose some).
- We could add an option in our player SDK to remove a version (or versions) of the video. This would be client side, so not as secure as a server side approach. This is not currently on the dev teams roadmap, but we could add it in - if there is interest in its implementation.
Doug
Ok, so i am writing my own player and in this case i can modify the manifest throught my backend and give it to the user, erasing the latest 2 lines for 1080p users. What do you think? If it’s possible, where i find the manifest?
When you create or query a video with our API, the response will have an “Assets” section:
"assets":{
"iframe":"<iframe src="//embed.api.video/vi4k0jvEUuaTdRAEjQ4Jfrgz?token=831a9bd9-9f50-464c-a369-8e9d914371ae" ..."
"player":"https://embed.api.video/vi4k0jvEUuaTdRAEjQ4Jfrgz?token=831a9bd9-9f50-464c-a369-8e9d914371ae"
"hls":"https://cdn.api.video/stream/831a9bd9-9f50-464c-a369-8e9d914371ae/hls/manifest.m3u8"
"thumbnail":"https://cdn.api.video/stream/831a9bd9-9f50-464c-a369-8e9d914371ae/thumbnail.jpg"
"mp4":"https://cdn.api.video/vod/vi4k0jvEUuaTdRAEjQ4Jfrgz/token/8fd70443-d9f0-45d2-b01c-12c8cfc707c9/mp4/72 ..."
}
Note: this response is for a private video, as there is a 1 use token in each url. If your video is public the token will not appear in the response
You want the HLS file - a link right to the manifest of the video.
- iframe url: for embedding on the web
- player url: for watching right away
- the HLS (what you want in this case)
- thumbnail: the image used as poster
- mp4: this will be the 1080p mp4 link.
Doug