function parseInitSegment(initSegment) {
  var result = [];
  var traks = findBox(initSegment, ['moov', 'trak']);

  for (var i = 0; i < traks.length; i++) {
    var trak = traks[i];
    var tkhd = findBox(trak, ['tkhd'])[0];

    if (tkhd) {
      var version = tkhd.data[tkhd.start];

      var _index = version === 0 ? 12 : 20;

      var trackId = readUint32(tkhd, _index);
      var mdhd = findBox(trak, ['mdia', 'mdhd'])[0];

      if (mdhd) {
        version = mdhd.data[mdhd.start];
        _index = version === 0 ? 12 : 20;
        var timescale = readUint32(mdhd, _index);
        var hdlr = findBox(trak, ['mdia', 'hdlr'])[0];

        if (hdlr) {
          var hdlrType = bin2str(hdlr.data.subarray(hdlr.start + 8, hdlr.start + 12));
          var type = {
            soun: _loader_fragment__WEBPACK_IMPORTED_MODULE_1__["ElementaryStreamTypes"].AUDIO,
            vide: _loader_fragment__WEBPACK_IMPORTED_MODULE_1__["ElementaryStreamTypes"].VIDEO
          }[hdlrType];

          if (type) {
            // Parse codec details
            var stsd = findBox(trak, ['mdia', 'minf', 'stbl', 'stsd'])[0];
            var codec = void 0;

            if (stsd) {
              codec = bin2str(stsd.data.subarray(stsd.start + 12, stsd.start + 16)); // TODO: Parse codec details to be able to build MIME type.
              // stsd.start += 8;
              // const codecBox = findBox(stsd, [codec])[0];
              // if (codecBox) {
              //   TODO: Codec parsing support for avc1, mp4a, hevc, av01...
              // }
            }

            result[trackId] = {
              timescale: timescale,
              type: type
            };
            result[type] = {
              timescale: timescale,
              id: trackId,
              codec: codec
            };
          }
        }
      }
    }
  }

  var trex = findBox(initSegment, ['moov', 'mvex', 'trex']);
  trex.forEach(function (trex) {
    var trackId = readUint32(trex, 4);
    var track = result[trackId];

    if (track) {
      track.default = {
        duration: readUint32(trex, 12),
        flags: readUint32(trex, 20)
      };
    }
  });
  return result;
}
Parses an MP4 initialization segment and extracts stream type and
timescale values for any declared tracks. Timescale values indicate the
number of clock ticks per second to assume for time-based values
elsewhere in the MP4.

To determine the start time of an MP4, you need two pieces of
information: the timescale unit and the earliest base media decode
time. Multiple timescales can be specified within an MP4 but the
base media decode time is always expressed in the timescale from
the media header box for the track:
```
moov > trak > mdia > mdhd.timescale
moov > trak > mdia > hdlr
```
@param initSegment {Uint8Array} the bytes of the init segment
@return {InitData} a hash of track type to timescale values or null if
the init segment is malformed.