private static uint CalculateBitrate(SegmentIndexBox sidx)
        {
            var trackSize     = sidx.Subsegments.Sum(subsegment => (long)subsegment.ReferencedSize); // Track size in bits
            var trackDuration = sidx.Subsegments.Sum(subsegment => (long)subsegment.Duration);       // Track duration
            var bitrate       = ((double)(trackSize * 8) / (double)trackDuration) * (double)sidx.Timescale;

            return((uint)bitrate);
        }
        private static IEnumerable <SmoothStreamingMediaStreamIndexC> CreateChunks(SegmentIndexBox sidx)
        {
            int i = 0;

            foreach (var subsegment in sidx.Subsegments)
            {
                var c = new SmoothStreamingMediaStreamIndexC();
                if (i == 0)
                {
                    c.t = sidx.EarliestPresentationTime;
                }
                c.n = i;
                c.d = subsegment.Duration;
                //c.d = ConvertTimeToTimescale(track.Duration, mvhd.TimeScale, track.TimeScale) - entriesDuration;
                yield return(c);
            }
        }
        private static IEnumerable <KeyValuePair <string, ChunkLocation> > GetChunkLookups(SmoothStreamingMediaStreamIndex streamIndex, SmoothStreamingMediaStreamIndexQualityLevel track, Uri chunkUri, SegmentIndexBox sidx)
        {
            int   i          = 0;
            ulong byteOffset = sidx.FirstOffset;
            ulong timeOffset = 0;

            foreach (var c in streamIndex.c)
            {
                var subsegment = sidx.Subsegments[i];
                // create a lookup table for each chunk
                var key = "/" + streamIndex.Url
                          .Replace("{bitrate}", track.Bitrate.ToString())
                          .Replace("{start time}", timeOffset.ToString());

                var location = new ChunkLocation()
                {
                    Uri  = chunkUri,
                    From = byteOffset,
                    To   = byteOffset += subsegment.ReferencedSize
                };
                yield return(new KeyValuePair <string, ChunkLocation>(key, location));

                timeOffset += subsegment.Duration;
                i++;
            }
        }