Playback of a multicast DASH stream in dash.js using the 5G-MAG Reference Tools

Typically, media streaming in browser-based environments is based on unicast delivery. Streaming services such as Netflix, DAZN, Amazon Prime, Disney and Youtube use Content Delivery Networks (CDNs) to deliver media segments and manifest files in a one-to-one (unicast) fashion to their customers.

Especially for large-scale events the delivery of multicast streams can have a large impact on the scalability and the costs of streaming services. Ideally, the main content like a sports game can be multicasted to all viewers while preserving the benefits of classic unicast streaming such as personalized advertisements or the option to switch between different languages or camera angles. In this blog post we will explore an implementation that uses the 5G-MAG Reference Tools to receive a multicast DASH stream and provide the manifest files and the media segments to the dash.js player for final playback.

5G-MAG Reference Tools – LTE-based 5G broadcast

To understand the idea behind the components that we will use it is important to understand the idea of the “5G-MAG Reference Tools” and the concept of “LTE-based 5G broadcast”. LTE-based 5G broadcast, widely known as 5G Broadcast, allows linear TV and radio to be broadcasted to compatible 3GPP-based devices like smartphones, tablets, home gateways and connected cars. It is defined in 3GPP and uses Rel-16 features based on an LTE infrastructure. Detailed information about the LTE-based 5G broadcast technology can be found in various related 3GPP and ETSI specifications such as ETSI TS 103 720, 3GPP TS 23.246, 26.346 and 26.347.
The 5G-MAG Reference Tools project was started in late 2021 with the goal to create open-source reference tools to support implementation and interoperability of 5G Media technologies. The initial focus of the project was the implementation of LTE-based 5G broadcast. Since its start, the steadily growing developer community has added various features to the open-source project such as support for real-time object delivery over unidirectional transport (ROUTE) and the possibility to dynamically switch between broadcast and unicast delivery (seamless switching).

Multicast DASH playback in dash.js – The big picture

In our multicast DASH demo we will not use all the 5G-MAG components. As we do not work with a real 5G broadcast we can omit the lower part of the Reference Tools, namely the MBMS Modem. Our basic setup is depicted in the illustration below:

The idea of this workflow is simple: We use ffmpeg to create a DASH livestream from a local media file. The manifest files and the media segments are written to a watchfolder. Once new files are added to the watchfolder we use the 5G-MAG Reference Tools – FLUTE Transmitter to File Delivery over Unidirectional Transport (FLUTE) encode the files and multicast them to the 5G-MAG Reference Tools – MBMS Middleware (rt-mbms-mw). The MBMS Middleware decodes the files using the FLUTE Decoder and saves them on a local server. From the local server the files are accessible in a DASH player such as dash.js via a Nginx Reverse Proxy. Let’s look at the individual steps in more detail:

Step 1: Initializing the MBMS Middleware

The original purpose of the MBMS Middleware is to communicate with the MBMS Modem. Similar to what we will do later, the MBMS Modem outputs a multicast to be processed by the MBMS Middleware. In addition, specific initialization information such as the multicast address are provided by the MBMS Modem to the MBMS Middleware via a REST interface. To utilize the MBMS Middleware for our purposes we need to provide this initialization information in a similar manner. Consequently, we implemented a simple HTTP server that exposes the required routes and replaces the corresponding functionality of the MBMS Modem.

Moreover, MBMS services are announced using a service announcement (SA) file. The SA includes information about the service parameters required for service activation, for example IP multicast addresses and service start times. Again, we provide a static file to the MBMS Middleware to reuse the existing 5G-broadcast based implementation. This time the information is FLUTE encoded and multicasted using the FLUTE Transmitter.

Step 2: Preparing the DASH livestream

To be able to multicast our DASH manifest files and media segments we need to create a DASH livestream. In our demo we use ffmpeg to achieve this. A sample command for ffmpeg looks like this:

ffmpeg \
\
-re -fflags +genpts -stream_loop -1 -i content/01_llama_drama_1080p.mp4 \
\
-flags +global_header -r 30000/1000 \
\
-filter_complex "drawbox=x=1460:y=0:width=460:height=100:color=black@0.5:t=fill,\
split=2[s0][s1];\
[s0]drawtext=text='720p-2.0M':x=1480:y=20:\
fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:fontsize=80:fontcolor=white,\
scale=1280x720[s0];\
[s1]drawtext=text='540p-1.0M':x=1480:y=20:\
fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:fontsize=80:fontcolor=white,\
scale=960x540[s1]" \
\
-pix_fmt yuv420p \
-c:v libx264 \
\
-b:v:0 2000K -maxrate:v:0 2000K -bufsize:v:0 2000K/2 \
-b:v:1 750K -maxrate:v:1 750K -bufsize:v:1 750K/2 \
\
-g:v 60 -keyint_min:v 60 -sc_threshold:v 0 \
\
-color_primaries bt709 -color_trc bt709 -colorspace bt709 \
\
-c:a aac -ar 48000 -b:a 128k \
\
-map [s0] -map [s1] \
-map 0:a:0 \
\
-preset veryfast \
-tune zerolatency \
\
-use_template 1 \
-use_timeline 1 \
-window_size 50 \
-remove_at_exit 1 \
-adaptation_sets 'id=0,streams=v id=1,streams=a' \
-f dash /var/www/watchfolder_out/index.mpd

We simply loop a VoD file and create two video representations (1280×720@2Mbit/s, 960×540@0.75Mbit/s) and one audio representation. The output is written to our watchfolder.

Step 3: FLUTE encoding and multicasting the DASH files

Now that our livestream is up and running we can monitor the watchfolder for changes. Once new files are added or existing files are modified we use the FLUTE transmitter to multicast them to the MBMS Middleware.

Step 4: Receiving the multicast and preparing the files

On the MBMS Middleware we constantly receive manifest files and media segments via multicast. We use the FLUTE library to decode the files. For the player to fetch the files via localhost we need to make sure to set the right values for the <Location> and the <BaseURL> elements in the manifest. This manifest manipulation is done by the MBMS Middleware before saving the files on the local file server. In addition, we use an Nginx proxy for the mapping of the standard ports 80/443 to the internal ports of the MBMS middleware.

Step 5: Playback in dash.js

Now that we have received and FLUTE decoded the manifest files and the media segments we can play them in our favorite media player. In our example we use dash.js for browser-based playback. For the media player itself it is not visible that the files originated from multicast. The requests for the MPD and the media segments are done in compliance with the <Location> and the <BaseURL> elements, both pointing to localhost.

What’s next

The demo we went through in this blog post will soon be available as part of the open-source 5G-MAG Reference tools. This blog post covers just a small part of what the 5G-MAG Reference Tools can do. The possibility to seamlessly switch between broadcast/multicast content and provide personalized unicast ads or additional audio and video tracks offers great possibilities.

If you are interested in our activities regarding 5G, 5G broadcast, 5G Media Streaming or streaming in general checkout the following links:

Leave a Reply

Your email address will not be published. Required fields are marked *