Ejemplo n.º 1
0
        public void ConcatParts(VodPlaylist vodPlaylist, string concatFile)
        {
            //setStatus("Merging files");
            //setProgress(0);

            //log(Environment.NewLine + Environment.NewLine + "Merging all VOD parts into '" + concatFile + "'...");

            using (FileStream outputStream = new FileStream(concatFile, FileMode.OpenOrCreate, FileAccess.Write))
            {
                int partsCount = vodPlaylist.Count;

                for (int i = 0; i < partsCount; i++)
                {
                    VodPlaylistPart part = vodPlaylist[i];

                    using (FileStream partStream = new FileStream(part.LocalFile, FileMode.Open, FileAccess.Read))
                    {
                        int    maxBytes;
                        byte[] buffer = new byte[4096];

                        while ((maxBytes = partStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            outputStream.Write(buffer, 0, maxBytes);
                        }
                    }

                    FileSystem.DeleteFile(part.LocalFile);

                    StateHandler(string.Format("Merging... {0}/{1} {2} %", i + 1, partsCount, Math.Round(((i + 1) / ((float)partsCount)) * 100).ToString()));
                }

                StateHandler("Merging... 100 %");
            }
        }
Ejemplo n.º 2
0
        public static VodPlaylist Parse(string tempDir, string playlistStr, string urlPrefix)
        {
            VodPlaylist playlist = new VodPlaylist();

            List <string> lines = playlistStr.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            int partCounter = 0;

            for (int i = 0; i < lines.Count; i++)
            {
                string line = lines[i];

                if (line.StartsWith("#EXTINF", StringComparison.OrdinalIgnoreCase))
                {
                    double length = Math.Max(double.Parse(line.Substring(line.LastIndexOf(":") + 1).TrimEnd(','), NumberStyles.Any, CultureInfo.InvariantCulture), 0);

                    playlist.Add(new VodPlaylistPart(length, urlPrefix + lines[i + 1], Path.Combine(tempDir, partCounter.ToString("D8") + ".ts"), partCounter));
                    partCounter++;
                    i++;
                }
            }

            return(playlist);
        }
Ejemplo n.º 3
0
 private void TimerHandler(object sender, ElapsedEventArgs e)
 {
     CheckOutputDirectory("temp" + Id);
     VodPlaylist vodPlaylists = TwitchService.RetrieveVodPlaylist("temp" + Id, playlistUrl);
 }