Esempio n. 1
0
        private string CombineFragments(MediaPresentationDescription mpd, string mpdFilePath, string outputFilePath)
        {
            var walker = new MpdWalker(mpd);
            var track  = walker.GetTracksFor(TrackContentType.Video).First();
            var trackRepresentation = track.TrackRepresentations.OrderByDescending(r => r.Bandwidth).First();

            using (var stream = File.OpenWrite(outputFilePath))
                using (var writer = new BinaryWriter(stream))
                {
                    string fragmentPath = Path.Combine(Path.GetDirectoryName(mpdFilePath), trackRepresentation.InitFragmentPath);
                    writer.Write(File.ReadAllBytes(fragmentPath));

                    foreach (var path in trackRepresentation.FragmentsPaths)
                    {
                        fragmentPath = Path.Combine(Path.GetDirectoryName(mpdFilePath), path);
                        if (!File.Exists(fragmentPath))
                        {
                            break;
                        }
                        writer.Write(File.ReadAllBytes(fragmentPath));
                    }
                }

            return(outputFilePath);
        }
Esempio n. 2
0
        private MediaPresentationDescription DownloadMpd()
        {
            if (!Directory.Exists(destinationDir))
            {
                Directory.CreateDirectory(destinationDir);
            }
            else
            {
                Directory.GetFiles(destinationDir).ToList().ForEach(f => File.Delete(f));
            }

            return(MediaPresentationDescription.FromUrl(mpdUrl, mpdFileName.Value));
        }
Esempio n. 3
0
 public MpdWalker(MediaPresentationDescription mpd)
 {
     this.mpd = mpd;
 }