Dynamic bit-rate RTMP streaming via CloudFront with JWPlayer


CloudFront is a service in AWS, which has serves as CDN for downloadable data and stream-able data. Videos stored in Amazon S3 can be streamed using CloudFront which is in rtmp format. Here in this post I am going  to make a multi-bitrate selection for videos in JW Player which will have a result as shown in the below picture where we can choose bit-rate of videos to be played:

The code for the player page is as follows:
<html>
<head>
    <script src="http://jwpsrv.com/library/H5ZwPmjuEe.js"></script>
</head>
<body>

<div id="mediaplayer">
Loading the player...
</div>
<script type="text/javascript">
   jwplayer('mediaplayer').setup({
        playlist: [{
            sources: [{
                file: "videos_playlist.smil"
                }]
            }],
            primary: "flash"
   });
</script>
</body>
</html>
Now lets create Synchronized Multimedia Integration Language (SMIL) file which will define the videos to be played for the selected bitrate.
<smil>
  <head>
    <meta base="rtmp://s2as2xpom4wy97.cloudfront.net:1935/cfx/st/"/>
  </head>
  <body>
    <switch>
 <video src="sample-720p.mp4" system-bitrate="720000" />
 <video src="sample-360p.mp4" system-bitrate="3600000" />
 <video src="sample-120p.mp4" system-bitrate="120000" />
    </switch>
  </body>
</smil>

This system is not only for use with RTMP stream served by CloudFront but you can use with your own RTMP VOD streams.

Comments

Popular posts from this blog

Automate file upload in Selenium IDE

How To Install and Configure Nextcloud