Video Everything
Repository with minimal samples for playing HLS/DASH with CMAF video, across as many platforms as possible.
Content and License
All test content in this repository was derived from the Netflix Open Source Content Platform which is licensed under the Creative Commons Attribution 4.0 International Public License
Currently the following titles exist as test media:
If you would like to follow along and encode your own piece of test content, refer to the Content Preparation section below.
Setup
Ensure you have:
- Node/NPM
- Web Browsers
- Android Studio
- Xcode
Optional things:
- Physical devices
Hosting Content
You can point the samples at any content, but to get things off the ground this repo contains a sample encoded HLS/DASH with CMAF playlist with a two bitrate variations located in the .content
directory.
Before moving on to each platform, pop into that directory and run:
Samples
Web, Mobile Web
Inside of the /web
directory:
Then navigate to the individual pages. Note that the html5
sample will only work in Safari, or any browser that natively supports HLS and fMP4 (Fragmented MP4).
Samples available:
Android, Android TV, FireTV
Inside of the /android
and /androidtv-firetv
directories respectively, open Android Studio to the root build.gradle
files. Build and run the apps on your device of choice.
Samples available:
iOS, tvOS, macOS
Inside of the /ios-tvos-macos
directory, open Xcode to the project files. Build and run the apps on your device of choice, across the build targets.
Samples available:
Roku
Inside of the /roku
directory:
There will be build generated here: ./out/roku.zip
To view on a Roku device, make sure your Roku is in developer mode and install the application by uploading the generated zip file to the Development Application Installer screen.
Note: the Roku device must be on the same network as the server hosting the content. The build command assumes your are hosting the content on the machine you are building on.
Tizen
TODO
WebOS
TODO
Chromecast
TODO
PlayStation
TODO
XBox
TODO
OTT
TODO
Content Preparation
If you would like to prepare and use your own piece of media, the following section will walk you through the steps to properly encode and package sample content which can be played using the samples configured in this repo. Once packaged the content can be placed in the .content/public
directory.
For the sample content included in this repo the following transmuxing, transcoding, and packaging steps were performed.
Content Download
To start, download the full Sol Levante 35GB HDR10 2020 ST2084 UHD source media file from the Netflix Open Source Content Platform above.
Content Re-Mux for Size Reduction
To work with a file of this size it's easier if we trim it down right from the start. We'll use a combination of ffmpeg
and bento4
throughout this process, but any media tools with sufficient spec compliance and codec support will do.
First we'll trim the video down to a 15 second section:
Content Transcode/Transmux
Now we'll transcode/transmux the .mov
QuickTime file to h.264 AAC:
Content Renditions
Next we'll generate a 360p and 480p rendition of the new source content, using the Shaka Media Packager demo settings. These account for the correct GOP (Group of Pictures) alignment and bitrate settings.
Content to Fragmented MP4s (fMP4s)
At this point we have two renditions of h.264 AAC mp4 content. In order to package this as CMAF we'll need to first transcode the content so it's fragmented. Internally this is just converting the actual sections of media data (mdat
) into consistently sized boxes, which in this case we'll make 3s to align with CMAF spec recommendations for compatibility between HLS and DASH.
To do the final steps we'll use bento4
. This packaging libraries requires the input renditions to be packaged are first fragmented:
Content Packaging
At this point we can wrap up our two fragmented renditions and host them under our .content
directory:
This produces a content
directory in the same structure as provided under the .content/sol-levante
section.
Content Profile Downgrade
Right now the content profile is encoded as High
, and ffmpeg was complaining about the inability to transcode the source media which already encoded with a high profile. If you need to tweak the profile you can use the following snippet: