(Available in DuraCloud 5.0.0+)
HTTP Live Streaming (HLS) is an HTTP-based streaming protocol which supports delivery of adaptive bitrate video and audio streams. DuraCloud makes use of Amazon CloudFront to deliver its HLS streaming capability, so streaming content must be stored in the Amazon S3 storage provider to take advantage of this feature.
Media files must be transcoded into a format which is supported by HLS before streaming may occur. Typically transcoding results in a set of .ts segment files which contain the media in time-boxed fragments and .m3u8 index files which are used to capture the ordering and combinations of .ts files for playback.
Further background and information about HLS can be found on: wikipedia, encoding.com, and apple.com (as well as many other sites).
DuraCloud supports two different types of HLS streaming, open and secure. Open streaming allows anyone with access to the URL for a content item (in a space where open streaming is enabled) to stream that content. The exception to this is if the allowedOrigins parameter is utilized when enabling HLS streaming for a space, which limits browser-based (JavaScript) streaming requests to only certain hosts.
Secure streaming requires that permission be granted before a user is able to stream a file. Your web application will need to determine if the user has the necessary rights, and if so, allow a set of cookies to be set on that user's browser. Those cookies are used to verify that the user has permission to stream the files in a space. The request to generate those cookies can set further limits, such as the length of time the user will have access and the IP address range where the streaming is allowed to take place. The purpose of secure streaming is to restrict the use of the stream. This is ideal for scenarios where streamed content is not free to use or must only be provided to a limited audience.
Follow these steps to stream media files with DuraCloud using HLS
In order for media to be streamed from a space with secure streaming enabled, a set of cookies must first be set on the user's browser. These cookies provide the policy and signature used by Amazon CloudFront to verify that the user has permission to retrieve the files. One set of cookies applies to all content in a space. Each streamed space has its own streaming host and associated cookies.
Due to browser security requirements, cookies which apply to a domain can only be set in a response from that domain. In order to set cookies which apply to the CloudFront streaming domain, a call needs to be made to CloudFront by the user which results in the cookies being provided in the response. To make this happen, your web application (which is allowing the user to discover the streamed content) must interact with DuraCloud and the user following these steps:
The following diagram shows the flow of control described in the previous steps. The diagram uses a video list page as an example of a page the user could request from your web application, but this could be any page. The Web Application component is written and managed by the DuraCloud subscriber.
While this diagram may seem complex, the vast majority of the work is done for you by DuraCloud and CloudFront. As noted above, you need to make one call to retrieve the signed cookies URL, then respond to the user redirecting them to that URL. The rest of the flow for setting cookies is handled outside of your application. The user is then returned to your application in order to continue to search for media content, and that content is displayed in the same way as with open streaming.
The Media Streaming capabilities provided by DuraCloud allow video and audio files to be streamed over RTMP. This feature in DuraCloud takes advantage of Amazon CloudFront streaming, so files to be streamed must be within spaces on an Amazon provider. This type of streaming uses the Flash Media Server to host streaming files over RTMP. File formats supported include MP3, MP4 and FLV among others. For a full listing of supported file types see the Flash Media Server documentation.
DuraCloud supports two different types of RTMP streaming, open and secure. Open streaming allows anyone with access to the URL for a streamed content item to stream the content. This works well for open access content which is intended to be shared and accessed widely. Secure streaming requires that a request be made to DuraCloud to retrieve a signed URL. That signed URL can then be used to stream the file. The request to retrieve a signed URL can specify how long the content will be available to stream (the default is 8 hours) as well as the IP address or IP address range where the streaming is allowed to take place. The purpose of secure streaming is to restrict the use of the stream. This is ideal for scenarios where streamed content is not free to use or must only be provided to a limited audience. Note that both types of streaming, open and secure, use the RTMP protocol, which requires that a flash-based streaming media player be used to play the streamed content.
Follow these steps to stream media files with DuraCloud using RTMP
The Flash Media Server used by Amazon CloudFront and media players like JWPlayer and Flowplayer require certain specific conventions for requesting streamed files. There are two primary variables, one being a prefix which may need to precede the file name (example prefix values are "mp3:" and "mp4:"). The other variable is whether a file extension is allowed on the file name. Getting these combinations right is particularly important when using secure streaming, as the player cannot request the file with alternative file names to match its preferences. Not all file types use the same combination of prefix and file extension settings. For example, it is common for MP4 files to require a prefix and extension (example file name: "mp4:videofile.mp4") while MP3 files require a prefix but no extension (example file name: "mp3:audiofile"). The prefix value, when needed, should be added to the stream path by using the "resourcePrefix" parameter on the get-url or get-signed-url call made through the DuraCloud REST API. In most cases, the file extension will need to be part of the stored file name. Even if files are named with a file extension (which is typically the case), calls to retrieve a streaming URL can specify the file name with no extension. |
If the streaming media player is not displayed in DuraCloud after you enable streaming (and select a content item), then the Flash player may not be enabled in your browser. In Google Chrome, go to: chrome://settings/content/flash, then add "https://[*.]duracloud.org" into the Allow section. Once this setting is in place, refresh the DuraCloud UI page, and the viewer should appear. Other browsers may require an add-on or a similar series of steps to enable Flash. |
The following files are available as a bundle here.
They are intended as a starting point for integrating streaming media into your own website.
All of the above files are intended as examples only. Their purpose is to give developers a starting point for embedding video streamed by DuraCloud on their own web pages.
If you add files to a space with streaming turned on, those files will automatically be made available for streaming as well. |