Transcoding assets for Media Source Extensions
When working with Media Source Extensions, it is likely that you need to condition your assets before you can stream them. This article takes you through the requirements and shows you a toolchain you can use to encode your assets appropriately.
Getting started
- The first and most important step is to ensure that your files are comprised of a container and codec that users' browsers support.
- Depending on the codec, you might need to fragment the file to comply with the ISO BMFF spec .
- (Optional) If you decide to use Dynamic Adaptive Streaming over HTTP (DASH) for adaptive bitrate streaming, you need to transcode your assets into multiple resolutions. Most DASH clients expect a corresponding Media Presentation Description (MPD) manifest file, which is typically generated while generating the multiple resolution asset files.
Below we'll cover all of these steps, but first let's look at a toolchain we can use to do this fairly easily.
Sample Media
If you're looking to follow the steps listed here, but don't have any media to experiment with, you can grab the trailer to Big Buck Bunny . Big Buck Bunny copyrighted by the Blender Foundation and is licensed under the Creative Commons Attribution 3.0 license. Throughout this tutorial, you'll see the filename trailer_1080p.mov, which is the download.
Tools required
When working with MSE, the following tools are a must have:
bin
directory in the same place as ffmpeg.
Get these installed successfully before moving to the next step.
Sample media should be placed in the Bento4
utils
directory and worked here.
Note:
The prebuilt ffmpeg does not include libfdk_aac due to licensing reasons. Bento4 uses this by default, so you need to compile ffmpeg if necessary. If you don't need it, add
--audio-codec=aac
to the
mp4-dash-encode.py
command line.