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<SmoothStreamingMediaStreamIndexC> CreateChunks(SegmentTimeline segmentTimeline)
        {
            int i = 0;

            foreach (var s in segmentTimeline.S)
            {
                for (int repeatIndex = 0; repeatIndex <= s.R; repeatIndex++)
                {
                    var c = new SmoothStreamingMediaStreamIndexC();
                    c.n = i;
                    c.t = s.T;
                    c.d = s.D;
                    //c.d = ConvertTimeToTimescale(track.Duration, mvhd.TimeScale, track.TimeScale) - entriesDuration;

                    yield return c;
                    i++;

                }
            }
        }
        private static IEnumerable<SmoothStreamingMediaStreamIndexC> GenerateClientManifestChunks(ManifestTrack track, Box moov)
        {
            // Pull entries that point to different moof boxes, duplicate boxes offsets cause playback issues.
            var entries = track.Fragments.TrackFragmentRandomAccessEntries
                .GroupBy(entry => entry.MoofOffset)
                .Select(entry => entry.First())
                .ToList();
            ulong entriesDuration = 0;

            //create chunks
            for (int i = 0; i < entries.Count; i++)
            {
                var c = new SmoothStreamingMediaStreamIndexC();
                c.n = i;

                if (i != entries.Count - 1)
                {
                    // The duration is the difference between this entry and the next's time
                    c.d = entries.ElementAt(i + 1).Time - entries.ElementAt(i).Time;
                    entriesDuration += c.d;
                }
                else
                {
                    var mvhd = moov.InnerBoxes.SingleOrDefault(b => b.Type == BoxType.Mvhd) as MovieHeaderFullBox;
                    // Final duration is what we have left, the track duration is in the timescale of the presentation,
                    // so we have to convert to the timescale of the actual media in the track
                    c.d = ConvertTimeToTimescale(track.Duration, mvhd.TimeScale, track.TimeScale) - entriesDuration;
                }
                yield return c;
            }
        }