Giter VIP home page Giter VIP logo

hlssafariproxy's Introduction

How to make Token authorized AES encrypted HLS stream working in Safari

This code sample is a web proxy for making Token Authroized AES encrypted HLS stream working in Safari. Please check out this blog for more details: https://azure.microsoft.com/en-us/blog/how-to-make-token-authorized-aes-encrypted-hls-stream-working-in-safari/.

In order to use the project, you need to update the urlencoded_proxyurl to your site in index.cshtml file. All the manifest manipulation login is in manifestproxycontroller.cs file.

You could see a working version of this site at: http://mingfeiy.azurewebsites.net/.

hlssafariproxy's People

Contributors

dbgeorge avatar mingfeiy avatar sraje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hlssafariproxy's Issues

Code does not work (hosted sample does)

I've noticed that version of proxy hosted here: http://mingfeiy.azurewebsites.net/ is working. However, latest code version "d3fdebab10edc385076e8cc70424eccf12570644" yields different results and it's not working.

Can we please make sure that code in repository up-to-date with working example? It'd save developers' time...

Here is the proof. Let's take a sample from the page.

The URL to 1st level proxy is the following:

http://mingfeiy.azurewebsites.net/Home/Manifest?playbackUrl=http://amssamples.streaming.mediaservices.windows.net/830584f8-f0c8-4e41-968b-6538b9380aa5/TearsOfSteelTeaser.ism/manifest(format=m3u8-aapl)&webtoken=Bearer%3deyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiI5ZGRhMGJjYy01NmZiLTQxNDMtOWQzMi0zYWI5Y2M2ZWE4MGIiLCJpc3MiOiJodHRwOi8vdGVzdGFjcy5jb20vIiwiYXVkIjoidXJuOnRlc3QiLCJleHAiOjE3MTA4MDczODl9.lJXm5hmkp5ArRIAHqVJGefW2bcTzd91iZphoKDwa6w8

Here is first 3 lines from the response:

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="AAC_und_ch2_128kbps",URI="http://mingfeiy.azurewebsites.net/api/ManifestProxy?playbackUrl=http%3a%2f%2famssamples.streaming.mediaservices.windows.net%2f830584f8-f0c8-4e41-968b-6538b9380aa5%2fTearsOfSteelTeaser.ism/QualityLevels(125435)/Manifest(AAC_und_ch2_128kbps,format=m3u8-aapl)&token=Bearer%3deyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiI5ZGRhMGJjYy01NmZiLTQxNDMtOWQzMi0zYWI5Y2M2ZWE4MGIiLCJpc3MiOiJodHRwOi8vdGVzdGFjcy5jb20vIiwiYXVkIjoidXJuOnRlc3QiLCJleHAiOjE3MTA4MDczODl9.lJXm5hmkp5ArRIAHqVJGefW2bcTzd91iZphoKDwa6w8"

This response is correct. And here is what the code in the repo yields for the same input.

#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="AAC_und_ch2_128kbps",URI="QualityLevels(125435)/Manifest(AAC_und_ch2_128kbps,format=m3u8-aapl)"

Here is online runnable code snippet that mirrors the current repo code: http://rextester.com/VOKH35266.

HLSSafariProxy with PHP

Hi Mingfei Yan,

Thank you for this solution you save day. I have translated your controller code to PHP

AES with the closed captioning.

We have an asset with added text track.
When we try to stream the video on ios/mac devices without content protection everything is fine and user can see closed captions. But when I turn on the content protection (now we modify azure response via hls proxy) closed captions are not rendered. I suspect that something should be added to the proxy to render closed captioning but can't get what exactly.
@mingfeiy do you have any idea how to resolve it?
Thank you

Latest HLS proxy video play issue

We've setup the proxy, by taking the latest pull.

If we enter the token and Manifest URL here at http://mingfeiy.azurewebsites.net/ setup, and get the HLS URL, and open this on safari or in iPhone SKD's AVPlayerViewController it plays the video fine.

If we enter the token and Manifest URL to our proxy setup, get the HLS URL, provide this to iPhone safari or even in iPhone SDK, it doesn't play the video.

Here're the scenarios, so far:

  1. We had to provide the token to http://mingfeiy.azurewebsites.net/ proxy with a prefix of Bearer=long_long_long_token which works fine.
  2. If we enter the same Bearer=long_long_long_token to our proxy setup, it can't play the video on the embedded AzurePlayer on home page, and it shows Unable to decrypt the encrypted video source 0x20500004
  3. If we enter token without Bearer= prefix, it can play the video on the homepage in embedded AzurePlayer. But the HLS URL generated isn't playing the video on safari or in iPhone sdk.

What changes have been introduced b/w both versions that are preventing the latest proxy to play the video? Or are we missing something else?

Does not work when Asset name Includes the space due to improper encoding

The code is the repository and sample does not work when the Asset Name contains the space. It's due to improper URL encoding.

It makes 2nd level HLS playlist to contain malformed URIs like that (notice not encoded spaces):

#EXTINF:6.006000,no-desc
http://xxxx.streaming.mediaservices.windows.net/00000000-b4bd-4800-8d88-8fbbc0f53a41/SpaceX Interplanetary Transport System 2.ism/QualityLevels(394896)/Fragments(video=180180000,format=m3u8-aapl)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.