Working with HDS Bootstrap Data
I’ve always been curious about the bootstrap data for HDS content. Recently, I had the chance to find out more about it and get in some fun development with Node.js. We’ve been kicking around the idea of building a tool set for Adobe Media Server using Node.js and possibly socket.io. Last weekend we got some of the ideas going and one of those was parsing the hds bootstrap data created when content is packages for HDS delivery.
The bootstrap data can live in a couple of places:
- In the <metadata> node of an F4M file
- In an external .bootstrap file
The .bootstap file contains binary data and the F4M file contains the same binary data that has been Base64 encoded. So, getting to the data is pretty trivial – either read in the .bootstrap file or un-encode the string in that is in the F4M. Getting to the data contained in the bootstrap binary data is the fun part.
Understanding the bootstrap data
To do so, check out the F4V file format specification. This PDF gives you the details for the entire F4V file format. If you read through the PDF, you’ll see that it is built using what are called “boxes”. These boxes are given identifiers such as “abst”, “adaf”, “adkm”, “aeib”, “afra”, & “afrt” to name a few. Each box contains a header, that header identifies the box by its identifier and lets you know how much data is contained in the box. These boxes are also arranged into a hierarchy, so each box has some data that is specific to some part of the data contained in the file.
It is all in the boxes
The boxes that we are concerned with are “abst” or the bootstrap information box, “asrt” or the segement run table box, and “afrt” or the fragment run table box.
The abst box
The bootstrap information box contains information needed to bootstrap playing of HDS content – specifically to construct the URLs necessary to retrieve the fragments for playback. This includes information about the server, media, & segment information.
The asrt box
The segment run table box contains data about the segments for the media item. There can be multiple ASRT boxes – each representing a different quality level. There are some rules that you’ll want to pay attention to for the data in the asrt box:
- An asrt box can represent fragment runs for several quality levels.
- Each entry gives the first segment number for a run of segments with the same count of fragments.
- The count of segments having this same count of fragments can be calculated by subtracting the first segment number in this entry from the first segment number in the next entry.
The afrt box
The fragment run table box is used to find the fragment corresponding to a given time. Similar to the asrt box, there are some rules that you’ll want to pay attention to:
- Fragments are individually identifiable by the URL scheme based on segment number and fragments number.
- Fragments may vary both in duration and in number of samples.
- Duration of the fragments are stored in the this box.
- A Fragment Run Table may represent fragments for more than one quality level.
- Each fragment run table entry gives the first fragment number for a run of fragments with the same duration.
- The count of fragments having this same duration can be calculated by subtracting the first fragment number in this entry from the first fragment number in the next entry.
Parsing the bootstrap data using Node.js
Parsing binary data in Node.js can be done using “Buffer”. For the most part parsing the bootstrap data was pretty straight forward. There is one issue that I ran into with 64bit Integers which was solved easily enough (there are node modules for just about anything) using the node-int64 module to represent the 64Bit Integers. Once that was solved it was just a matter of parsing through the box header to figure out where you are in the dataset, and then creating the appropriate data structures to represent what you want and need in from the bootstrap data.
In our case we want to be able to monitor live events across multiple servers to make sure that they are all on the same segment and fragment. We’re building a services that in the case that something happens to a server and it goes haywire, will notify another service that can then restart or shut down that particular server or let caching servers know that they need to flush or refresh cache. We’re still dreaming up things we can use this type of data for.
Just want to get to that data?
If you have a .bootstrap file you can use the f4fpackager.exe that is part of the Adobe Media Server toolset to inspect the bootstrap data. All you need to do is run the tool with the argument “–inspect-bootstrap”. So the command looks something like the following if you have a bootstrap file named mydata.bootstrap:
.\f4fpackager.exe --input-file=mydata.bootstrap --inspect-bootstrap
Anyways, if you have any questions or input let me know in the comments.