KID it out — Putting Big Buck Bunny on a diet


Imagine this: You are coming home after a long day, ready to relax on your couch with a good book or an exciting movie. You are in front of your apartment, you have your key, but you can’t open the door. For some reason, the keyhole is blocked, and you can’t insert the key. Actually, something similar happened to my brother lately. He was coming home at 3 am, and an old tenant of the house had sealed the keyhole. He had to drive back the whole way to crash at a friend’s place. Different story though… In our case, the key is actually a license key, and we need it to decrypt our video. But for some reason, we can’t use this valid key/license.

We all enjoy streaming videos to our TVs. However, as developers, we know the dark side of media streaming. We know how painful it can be to develop applications for embedded devices such as Smart TVs or Set-Top boxes. Quite often something works very well on Desktop browsers but fails on embedded devices. Recently we were facing exactly such a situation. So, let me tell you the story about “Putting Big Buck Bunny on a diet“.

Chapter One – The ancient manuscript

We are at a very busy online bazaar. From one of the merchants, we buy a .zip surprise bag. It contains an ancient manuscript, a dusty device and piece of paper with a token and a URL on it. Our task: Use the device to decrypt and play the content that is described in the manuscript. First, we take a look at the manuscript. It contains some very weird symbols and seems to follow a certain structure. It looks like an XML and… wait, we have seen this before! This looks like a DASH MPD!

The dusty device looks familiar as well. It is a very old and simple Set-Top box that we can connect to our TV. Then the URL and the token on the paper can probably be used to fetch a license and decrypt whatever our DASH manifest is pointing to. Putting the pieces together and voilà: We see a video playing!

At least on our modern development device. Now let’s just confirm on the old Set-Top box, and we are done:

Well, it seems the friendly bunny we saw before is not that friendly anymore. It is stopping us from playing our content. And the only thing he tells us is the following:

MEDIA_ERR_SRC_NOT_SUPPORTED (No key ID available for encrypted sample)

Chapter Two – Those who control the past control the future

To quote George Orwell:

Those who control the present, control the past and those who control the past control the future

George Orwell

Let’s manipulate our manuscript (manifest) and check what happens. Maybe the angry bunny is only angry because we are feeding him too much information. What happens if we remove our Audio or our Video <AdaptationSet>? Are we still seeing the same error?

Now we don’t want to ruin our original manuscript. It might be valuable. Instead, we are creating our own copies of the manuscript for testing:

We are running a small MPD Proxy to manipulate outgoing manifest requests. The MPD proxy removes specific parts of the manifest, such as an <AdaptationSet> or a specific <Representation>. That way, we can check if our problem is limited to video or audio segments.

Unfortunately, playback is still not working and the bunny and his friends are making fun of us:

Chapter Three – KID it out – Cutting down on unhealthy boxes

Flashback to our childhood. What did we hate when we were kids? For me, it was broccoli. Having to finish my broccoli made me angry. Possibly we are feeding our bunny bad food? Perhaps he can’t digest one of the ISOBMFF boxes we are feeding him? Let’s take a look into our media segments to check what we can remove from the plate:

Well, look what we have here. A very unhealthy UUID box with a KID field. That is no good food for our KIDs (hope you got it) and also not good for our bunny. Let’s remove this from the menu:

Technical details: Modifying ISOBMFF media segments is not a simple task. Removing one of the ISOBMFF boxes requires changes in other boxes as well. The size and the dataOffset attributes of the parent boxes need to be adjusted. Our FAMIUM Packager solution which is part of our DASH toolchain is able to perform such complex operations. We used it to remove the problematic UUID box from a video segment to perform further tests.

Chapter Four – A special menu for a spoiled guest

Now let’s see how our special guest likes the new menu. We are not producing the new healthy segment in large numbers yet. So we need to create a custom menu that only selected guests are getting. Luckily, this is pretty easy to do. We just change our manuscript (manifest) again to point to our modified segment. We need to add some special ingredients such as a spicy @presentationTimeOffset to our manifest to make this work. In the end we get a static manifest instead of a dynamic one that we can easily use for testing:

 <SegmentTemplate initialization="video-$Bandwidth$-init.mp4" media="video-$Bandwidth$-$Number$-patched.m4s" startNumber="0" timescale="25">
<Representation bandwidth="2800000" codecs="avc1.4d401f" frameRate="25" height="540" id="Video1_1" sar="1:1" scanType="progressive" width="960" presentationTimeOffset="42835577159"/>

Chapter Five – A happy end

I admit, we are missing a climax in our story, so I will just move to the end: We made it! Our bunny likes his new menu so much, he decided to open the door lock for us (this is not a dirty joke) and let us use our valid license.

Speaking in technical terms again: The UUID box in the ISOBMFF segments caused the Set-Top box to throw an error regardless of the status of the license request. After removing the UUID box from the segments and creating a simple, static MPD, the content is playing successfully.

As for our bunny: It looks like he is tired of eating processed food, he is now hunting and cooking himself:

If you would like to try our digital menu yourself, we kindly invite you to join us in Berlin from June 11th – June 12th for the 11th FOKUS Media Web Symposium. The event is co-located with the dash.js face to face.

If you have any question regarding our DASH activities or dash.js in particular, feel free to check out our website and contact us.

Leave a Reply

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