Ejemplo n.º 1
0
        public TSPlaylistFile(
            BDROM bdrom,
            string name,
            List<TSStreamClip> clips)
        {
            BDROM = bdrom;
            Name = name;
            IsCustom = true;
            foreach (TSStreamClip clip in clips)
            {
                TSStreamClip newClip = new TSStreamClip(
                    clip.StreamFile, clip.StreamClipFile);

                newClip.Name = clip.Name;
                newClip.TimeIn = clip.TimeIn;
                newClip.TimeOut = clip.TimeOut;
                newClip.Length = newClip.TimeOut - newClip.TimeIn;
                newClip.RelativeTimeIn = TotalLength;
                newClip.RelativeTimeOut = newClip.RelativeTimeIn + newClip.Length;
                newClip.AngleIndex = clip.AngleIndex;
                newClip.Chapters.Add(clip.TimeIn);
                StreamClips.Add(newClip);

                if (newClip.AngleIndex > AngleCount)
                {
                    AngleCount = newClip.AngleIndex;
                }
                if (newClip.AngleIndex == 0)
                {
                    Chapters.Add(newClip.RelativeTimeIn);
                }
            }
            LoadStreamClips();
            IsInitialized = true;
        }
Ejemplo n.º 2
0
 public TSPlaylistFile(BDROM bdrom,
                       FileSystemMetadata fileInfo)
 {
     BDROM    = bdrom;
     FileInfo = fileInfo;
     Name     = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 3
0
        public Disc ReadBDROM(CancellationToken cancellationToken, string bdromPath)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return(null);
            }

            Host.ReportProgress(this, 0.0, "Scanning BD-ROM...");

            var bdrom = new BDInfo.BDROM(bdromPath);

            bdrom.ScanProgress += BDROMOnScanProgress;
            bdrom.Scan(cancellationToken);

            if (cancellationToken.IsCancellationRequested)
            {
                return(null);
            }

            Host.ReportProgress(this, 99.0, "Transforming BDInfo structure into BDHero structure...");

            var disc = DiscTransformer.Transform(bdrom);

            Host.ReportProgress(this, 100.0, "Finished scanning BD-ROM");

            return(disc);
        }
Ejemplo n.º 4
0
        public TSPlaylistFile(BDROM bdrom,
                              string name,
                              List <TSStreamClip> clips, IFileSystem fileSystem)
        {
            BDROM       = bdrom;
            Name        = name;
            _fileSystem = fileSystem;
            IsCustom    = true;
            foreach (var clip in clips)
            {
                var newClip = new TSStreamClip(
                    clip.StreamFile, clip.StreamClipFile);

                newClip.Name            = clip.Name;
                newClip.TimeIn          = clip.TimeIn;
                newClip.TimeOut         = clip.TimeOut;
                newClip.Length          = newClip.TimeOut - newClip.TimeIn;
                newClip.RelativeTimeIn  = TotalLength;
                newClip.RelativeTimeOut = newClip.RelativeTimeIn + newClip.Length;
                newClip.AngleIndex      = clip.AngleIndex;
                newClip.Chapters.Add(clip.TimeIn);
                StreamClips.Add(newClip);

                if (newClip.AngleIndex > AngleCount)
                {
                    AngleCount = newClip.AngleIndex;
                }
                if (newClip.AngleIndex == 0)
                {
                    Chapters.Add(newClip.RelativeTimeIn);
                }
            }
            LoadStreamClips();
            IsInitialized = true;
        }
Ejemplo n.º 5
0
 public TSPlaylistFile(
     BDROM bdrom,
     FileInfo fileInfo)
 {
     BDROM = bdrom;
     FileInfo = fileInfo;
     Name = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 6
0
 public TSPlaylistFile(
     BDROM bdrom,
     FileInfo fileInfo)
 {
   _settings = ServiceRegistration.Get<ISettingsManager>().Load<BDInfoSettings>() ?? new BDInfoSettings();
   BDROM = bdrom;
   FileInfo = fileInfo;
   Name = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 7
0
 public TSPlaylistFile(
     BDROM bdrom,
     FileInfo fileInfo)
 {
     _settings = ServiceRegistration.Get <ISettingsManager>().Load <BDInfoSettings>() ?? new BDInfoSettings();
     BDROM     = bdrom;
     FileInfo  = fileInfo;
     Name      = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 8
0
 public TSPlaylistFile(
     BDROM bdrom,
     FileInfo fileInfo)
 {
     BDROM     = bdrom;
     FileInfo  = fileInfo;
     DFileInfo = null;
     CdReader  = null;
     Name      = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 9
0
 public TSPlaylistFile(
     BDROM bdrom,
     FileSystemMetadata fileInfo, IFileSystem fileSystem, ITextEncoding textEncoding)
 {
     BDROM         = bdrom;
     FileInfo      = fileInfo;
     _fileSystem   = fileSystem;
     _textEncoding = textEncoding;
     Name          = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 10
0
        //private BackgroundWorker InitBDROMWorker = null;

        public void InitBDROM(string path)
        {
            System.Console.WriteLine("Please wait while we scan the disc...");
            try
            {
                BDROM = new BDROM(path);
                BDROM.StreamClipFileScanError += new BDROM.OnStreamClipFileScanError(BDROM_StreamClipFileScanError);
                BDROM.StreamFileScanError     += new BDROM.OnStreamFileScanError(BDROM_StreamFileScanError);
                BDROM.PlaylistFileScanError   += new BDROM.OnPlaylistFileScanError(BDROM_PlaylistFileScanError);
                BDROM.Scan();

                //System.Console.WriteLine(BDROM.DirectoryRoot.FullName);

                System.Console.WriteLine(string.Format("Detected BDMV Folder Full Path: {0}", BDROM.DirectoryBDMV.FullName));

                System.Console.WriteLine(string.Format("Disc Title: ({0})", BDROM.VolumeLabel));

                List <string> features = new List <string>();
                if (BDROM.Is50Hz)
                {
                    features.Add("50Hz Content");
                }
                if (BDROM.IsBDPlus)
                {
                    features.Add("BD+ Copy Protection");
                }
                if (BDROM.IsBDJava)
                {
                    features.Add("BD-Java");
                }
                if (BDROM.Is3D)
                {
                    features.Add("Blu-ray 3D");
                }
                if (BDROM.IsDBOX)
                {
                    features.Add("D-BOX Motion Code");
                }
                if (BDROM.IsPSP)
                {
                    features.Add("PSP Digital Copy");
                }
                if (features.Count > 0)
                {
                    System.Console.WriteLine("Detected Features: " + string.Join(", ", features.ToArray()));
                }

                System.Console.WriteLine(string.Format("Disc Size: {0:N0} bytes{1}", BDROM.Size, Environment.NewLine));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 11
0
        public FormPlaylist(string name, BDROM bdrom, OnCustomPlaylistFinished func)
        {
            InitializeComponent();

            textBoxName.Text = name;
            BDROM            = bdrom;
            OnFinished       = func;

            PlaylistColumnSorter = new ListViewColumnSorter();
            listViewPlaylistFiles.ListViewItemSorter = PlaylistColumnSorter;
        }
Ejemplo n.º 12
0
        public FormPlaylist(string name, BDROM bdrom, OnCustomPlaylistFinished func)
        {
            InitializeComponent();

            textBoxName.Text = name;
            BDROM = bdrom;
            OnFinished = func;

            PlaylistColumnSorter = new ListViewColumnSorter();
            listViewPlaylistFiles.ListViewItemSorter = PlaylistColumnSorter;
        }
Ejemplo n.º 13
0
 public TSPlaylistFile(
     BDROM bdrom,
     DiscFileInfo fileInfo,
     UdfReader reader)
 {
     BDROM     = bdrom;
     DFileInfo = fileInfo;
     FileInfo  = null;
     CdReader  = reader;
     Name      = fileInfo.Name.ToUpper();
 }
Ejemplo n.º 14
0
 public void InitBDROMWork(
     object sender,
     DoWorkEventArgs e
     )
 {
     try {
         BDROM = new BDROM((string)e.Argument);
         // BDROM.StreamClipFileScanError += new BDROM.OnStreamClipFileScanError(BDROM_StreamClipFileScanError);
         // BDROM.StreamFileScanError += new BDROM.OnStreamFileScanError(BDROM_StreamFileScanError);
         // BDROM.PlaylistFileScanError += new BDROM.OnPlaylistFileScanError(BDROM_PlaylistFileScanError);
         BDROM.Scan();
         e.Result = null;
     }
     catch (Exception ex) {
         e.Result = ex;
     }
 }
Ejemplo n.º 15
0
        public Disc ReadBDROM(CancellationToken cancellationToken, string bdromPath)
        {
            if (cancellationToken.IsCancellationRequested)
                return null;

            Host.ReportProgress(this, 0.0, "Scanning BD-ROM...");

            var bdrom = new BDInfo.BDROM(bdromPath);
            bdrom.ScanProgress += BDROMOnScanProgress;
            bdrom.Scan(cancellationToken);

            if (cancellationToken.IsCancellationRequested)
                return null;

            Host.ReportProgress(this, 99.0, "Transforming BDInfo structure into BDHero structure...");

            var disc = DiscTransformer.Transform(bdrom);

            Host.ReportProgress(this, 100.0, "Finished scanning BD-ROM");

            return disc;
        }
Ejemplo n.º 16
0
 private BDInfo.BDROM ScanBDROM(CancellationToken cancellationToken, string bdromPath)
 {
     try
     {
         var bdrom = new BDInfo.BDROM(bdromPath);
         bdrom.ScanProgress            += BDROMOnScanProgress;
         bdrom.PlaylistFileScanError   += BDROMOnPlaylistFileScanError;
         bdrom.StreamFileScanError     += BDROMOnStreamFileScanError;
         bdrom.StreamClipFileScanError += BDROMOnStreamClipFileScanError;
         bdrom.Scan(cancellationToken);
         return(bdrom);
     }
     catch (Exception e)
     {
         if (e is ArgumentException ||
             e is UnauthorizedAccessException ||
             e is IOException)
         {
             throw new ID10TException(e.Message, e);
         }
         throw;
     }
 }
Ejemplo n.º 17
0
        public TSPlaylistFile(
            BDROM bdrom,
            string name,
            List <TSStreamClip> clips)
        {
            _settings = ServiceRegistration.Get <ISettingsManager>().Load <BDInfoSettings>() ?? new BDInfoSettings();
            BDROM     = bdrom;
            Name      = name;
            IsCustom  = true;
            foreach (TSStreamClip clip in clips)
            {
                TSStreamClip newClip = new TSStreamClip(
                    clip.StreamFile, clip.StreamClipFile);

                newClip.Name            = clip.Name;
                newClip.TimeIn          = clip.TimeIn;
                newClip.TimeOut         = clip.TimeOut;
                newClip.Length          = newClip.TimeOut - newClip.TimeIn;
                newClip.RelativeTimeIn  = TotalLength;
                newClip.RelativeTimeOut = newClip.RelativeTimeIn + newClip.Length;
                newClip.AngleIndex      = clip.AngleIndex;
                newClip.Chapters.Add(clip.TimeIn);
                StreamClips.Add(newClip);

                if (newClip.AngleIndex > AngleCount)
                {
                    AngleCount = newClip.AngleIndex;
                }
                if (newClip.AngleIndex == 0)
                {
                    Chapters.Add(newClip.RelativeTimeIn);
                }
            }
            LoadStreamClips();
            IsInitialized = true;
        }
Ejemplo n.º 18
0
        public static string Generate(BDROM BDROM, List <TSPlaylistFile> playlists, ScanBDROMResult scanResult)
        {
            var report     = new StringBuilder();
            var protection = BDROM.IsBDPlus ? "BD+" : BDROM.IsUHD ? "AACS2" : "AACS";

            if (!string.IsNullOrEmpty(BDROM.DiscTitle))
            {
                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Disc Title:", BDROM.DiscTitle));
            }
            report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Disc Label:", BDROM.VolumeLabel));
            report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1:N0} bytes\r\n", "Disc Size:", BDROM.Size));
            report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Protection:", protection));

            var extraFeatures = new List <string>();

            if (BDROM.IsUHD)
            {
                extraFeatures.Add("Ultra HD");
            }
            if (BDROM.IsBDJava)
            {
                extraFeatures.Add("BD-Java");
            }
            if (BDROM.Is50Hz)
            {
                extraFeatures.Add("50Hz Content");
            }
            if (BDROM.Is3D)
            {
                extraFeatures.Add("Blu-ray 3D");
            }
            if (BDROM.IsDBOX)
            {
                extraFeatures.Add("D-BOX Motion Code");
            }
            if (BDROM.IsPSP)
            {
                extraFeatures.Add("PSP Digital Copy");
            }
            if (extraFeatures.Count > 0)
            {
                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Extras:", string.Join(", ", extraFeatures.ToArray())));
            }

            /*report.Append(string.Format(    CultureInfo.InvariantCulture,
             *                          "{0,-16}{1}\r\n", "BDInfo:",
             *                          Application.ProductVersion);*/

            report.Append("\r\n");
            report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Notes:", ""));
            report.Append("\r\n");
            report.Append("BDINFO HOME:\r\n");
            report.Append("  Cinema Squid (old)\r\n");
            report.Append("    http://www.cinemasquid.com/blu-ray/tools/bdinfo\r\n");
            report.Append("  UniqProject GitHub (new)\r\n");
            report.Append("   https://github.com/UniqProject/BDInfo\r\n");
            report.Append("\r\n");
            report.Append("INCLUDES FORUMS REPORT FOR:\r\n");
            report.Append("  AVS Forum Blu-ray Audio and Video Specifications Thread\r\n");
            report.Append("    http://www.avsforum.com/avs-vb/showthread.php?t=1155731\r\n");
            report.Append("\r\n");

            if (scanResult.ScanException != null)
            {
                report.Append(string.Format(CultureInfo.InvariantCulture, "WARNING: Report is incomplete because: {0}\r\n", scanResult.ScanException.Message));
            }
            if (scanResult.FileExceptions.Count > 0)
            {
                report.Append("WARNING: File errors were encountered during scan:\r\n");
                foreach (var fileName in scanResult.FileExceptions.Keys)
                {
                    var fileException = scanResult.FileExceptions[fileName];
                    report.Append(string.Format(CultureInfo.InvariantCulture, "\r\n{0}\t{1}\r\n", fileName, fileException.Message));
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0}\r\n", fileException.StackTrace));
                }
            }

            foreach (var playlist in playlists)
            {
                var summary = "";

                //                comboBoxPlaylist.Items.Add(playlist);

                var title    = playlist.Name;
                var discSize = string.Format(CultureInfo.InvariantCulture, "{0:N0}", BDROM.Size);

                var playlistTotalLength = new TimeSpan((long)(playlist.TotalLength * 10000000));
                var totalLength         = string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", playlistTotalLength.Hours,
                                                        playlistTotalLength.Minutes, playlistTotalLength.Seconds, playlistTotalLength.Milliseconds);

                var totalLengthShort = string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}", playlistTotalLength.Hours,
                                                     playlistTotalLength.Minutes, playlistTotalLength.Seconds);

                var totalSize = string.Format(CultureInfo.InvariantCulture, "{0:N0}", playlist.TotalSize);

                var totalBitrate = string.Format(CultureInfo.InvariantCulture, "{0:F2}", Math.Round((double)playlist.TotalBitRate / 10000) / 100);

                var playlistAngleLength = new TimeSpan((long)(playlist.TotalAngleLength * 10000000));

                var totalAngleLength = string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", playlistAngleLength.Hours,
                                                     playlistAngleLength.Minutes, playlistAngleLength.Seconds, playlistAngleLength.Milliseconds);

                var totalAngleSize = string.Format(CultureInfo.InvariantCulture, "{0:N0}", playlist.TotalAngleSize);

                var totalAngleBitrate = string.Format(CultureInfo.InvariantCulture, "{0:F2}", Math.Round((double)playlist.TotalAngleBitRate / 10000) / 100);

                var angleLengths       = new List <string>();
                var angleSizes         = new List <string>();
                var angleBitrates      = new List <string>();
                var angleTotalLengths  = new List <string>();
                var angleTotalSizes    = new List <string>();
                var angleTotalBitrates = new List <string>();
                if (playlist.AngleCount > 0)
                {
                    for (var angleIndex = 0; angleIndex < playlist.AngleCount; angleIndex++)
                    {
                        double angleLength    = 0;
                        ulong  angleSize      = 0;
                        ulong  angleTotalSize = 0;
                        if (angleIndex < playlist.AngleClips.Count && playlist.AngleClips[angleIndex] != null)
                        {
                            foreach (var clip in playlist.AngleClips[angleIndex].Values)
                            {
                                angleTotalSize += clip.PacketSize;
                                if (clip.AngleIndex == angleIndex + 1)
                                {
                                    angleSize   += clip.PacketSize;
                                    angleLength += clip.Length;
                                }
                            }
                        }

                        angleSizes.Add(string.Format(CultureInfo.InvariantCulture, "{0:N0}", angleSize));

                        var angleTimeSpan = new TimeSpan((long)(angleLength * 10000000));

                        angleLengths.Add(string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", angleTimeSpan.Hours, angleTimeSpan.Minutes,
                                                       angleTimeSpan.Seconds, angleTimeSpan.Milliseconds));

                        angleTotalSizes.Add(string.Format(CultureInfo.InvariantCulture, "{0:N0}", angleTotalSize));

                        angleTotalLengths.Add(totalLength);

                        double angleBitrate = 0;
                        if (angleLength > 0)
                        {
                            angleBitrate = Math.Round(angleSize * 8 / angleLength / 10000) / 100;
                        }
                        angleBitrates.Add(string.Format(CultureInfo.InvariantCulture, "{0:F2}", angleBitrate));

                        double angleTotalBitrate = 0;
                        if (playlist.TotalLength > 0)
                        {
                            angleTotalBitrate = Math.Round(angleTotalSize * 8 / playlist.TotalLength / 10000) / 100;
                        }
                        angleTotalBitrates.Add(string.Format(CultureInfo.InvariantCulture, "{0:F2}", angleTotalBitrate));
                    }
                }

                var videoCodec   = "";
                var videoBitrate = "";
                if (playlist.VideoStreams.Count > 0)
                {
                    TSStream videoStream = playlist.VideoStreams[0];
                    videoCodec   = videoStream.CodecAltName;
                    videoBitrate = string.Format(CultureInfo.InvariantCulture, "{0:F2}", Math.Round((double)videoStream.BitRate / 10000) / 100);
                }

                var audio1        = "";
                var languageCode1 = "";
                if (playlist.AudioStreams.Count > 0)
                {
                    var audioStream = playlist.AudioStreams[0];

                    languageCode1 = audioStream.LanguageCode;

                    audio1 = string.Format(CultureInfo.InvariantCulture, "{0} {1}", audioStream.CodecAltName, audioStream.ChannelDescription);

                    if (audioStream.BitRate > 0)
                    {
                        audio1 += string.Format(CultureInfo.InvariantCulture, " {0}Kbps", (int)Math.Round((double)audioStream.BitRate / 1000));
                    }

                    if (audioStream.SampleRate > 0 && audioStream.BitDepth > 0)
                    {
                        audio1 += string.Format(CultureInfo.InvariantCulture, " ({0}kHz/{1}-bit)", (int)Math.Round((double)audioStream.SampleRate / 1000),
                                                audioStream.BitDepth);
                    }
                }

                var audio2 = "";
                if (playlist.AudioStreams.Count > 1)
                {
                    for (var i = 1; i < playlist.AudioStreams.Count; i++)
                    {
                        var audioStream = playlist.AudioStreams[i];

                        if (audioStream.LanguageCode == languageCode1 && audioStream.StreamType != TSStreamType.AC3_PLUS_SECONDARY_AUDIO &&
                            audioStream.StreamType != TSStreamType.DTS_HD_SECONDARY_AUDIO &&
                            !(audioStream.StreamType == TSStreamType.AC3_AUDIO && audioStream.ChannelCount == 2))
                        {
                            audio2 = string.Format(CultureInfo.InvariantCulture, "{0} {1}", audioStream.CodecAltName, audioStream.ChannelDescription);

                            if (audioStream.BitRate > 0)
                            {
                                audio2 += string.Format(CultureInfo.InvariantCulture, " {0}Kbps", (int)Math.Round((double)audioStream.BitRate / 1000));
                            }

                            if (audioStream.SampleRate > 0 && audioStream.BitDepth > 0)
                            {
                                audio2 += string.Format(CultureInfo.InvariantCulture, " ({0}kHz/{1}-bit)",
                                                        (int)Math.Round((double)audioStream.SampleRate / 1000), audioStream.BitDepth);
                            }
                            break;
                        }
                    }
                }

                report.Append("\r\n");
                report.Append("********************\r\n");
                report.Append("PLAYLIST: " + playlist.Name + "\r\n");
                report.Append("********************\r\n");
                report.Append("\r\n");
                report.Append("<--- BEGIN FORUMS PASTE --->\r\n");
                report.Append("[code]\r\n");

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n", "", "", "", "", "",
                                            "Total", "Video", "", ""));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n", "Title", "Codec",
                                            "Length", "Movie Size", "Disc Size", "Bitrate", "Bitrate", "Main Audio Track", "Secondary Audio Track"));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n", "-----", "------",
                                            "-------", "--------------", "--------------", "-------", "-------", "------------------", "---------------------"));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n", title, videoCodec,
                                            totalLengthShort, totalSize, discSize, totalBitrate, videoBitrate, audio1, audio2));

                report.Append("[/code]\r\n");
                report.Append("\r\n");
                report.Append("[code]\r\n");

                report.Append("\r\n");
                report.Append("DISC INFO:\r\n");
                report.Append("\r\n");

                if (!string.IsNullOrEmpty(BDROM.DiscTitle))
                {
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Disc Title:", BDROM.DiscTitle));
                }

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Disc Label:", BDROM.VolumeLabel));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1:N0} bytes\r\n", "Disc Size:", BDROM.Size));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Protection:", protection));

                if (extraFeatures.Count > 0)
                {
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1}\r\n", "Extras:", string.Join(", ", extraFeatures.ToArray())));
                }

                /*report.Append(string.Format(CultureInfo.InvariantCulture,
                *                       "{0,-16}{1}\r\n", "BDInfo:", Application.ProductVersion);*/

                report.Append("\r\n");
                report.Append("PLAYLIST REPORT:\r\n");
                report.Append("\r\n");
                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1}\r\n", "Name:", title));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} (h:m:s.ms)\r\n", "Length:", totalLength));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1:N0} bytes\r\n", "Size:", totalSize));

                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} Mbps\r\n", "Total Bitrate:", totalBitrate));
                if (playlist.AngleCount > 0)
                {
                    for (var angleIndex = 0; angleIndex < playlist.AngleCount; angleIndex++)
                    {
                        report.Append("\r\n");
                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} (h:m:s.ms) / {2} (h:m:s.ms)\r\n",
                                                    string.Format(CultureInfo.InvariantCulture, "Angle {0} Length:", angleIndex + 1), angleLengths[angleIndex],
                                                    angleTotalLengths[angleIndex]));

                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1:N0} bytes / {2:N0} bytes\r\n",
                                                    string.Format(CultureInfo.InvariantCulture, "Angle {0} Size:", angleIndex + 1), angleSizes[angleIndex],
                                                    angleTotalSizes[angleIndex]));

                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} Mbps / {2} Mbps\r\n",
                                                    string.Format(CultureInfo.InvariantCulture, "Angle {0} Total Bitrate:", angleIndex + 1), angleBitrates[angleIndex],
                                                    angleTotalBitrates[angleIndex], angleIndex));
                    }

                    report.Append("\r\n");
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} (h:m:s.ms)\r\n", "All Angles Length:", totalAngleLength));

                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} bytes\r\n", "All Angles Size:", totalAngleSize));

                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1} Mbps\r\n", "All Angles Bitrate:", totalAngleBitrate));
                }

                /*
                 * report.Append(string.Format(
                 *  "{0,-24}{1}\r\n", "Description:", "");
                 */
                if (!string.IsNullOrEmpty(BDROM.DiscTitle))
                {
                    summary += string.Format(CultureInfo.InvariantCulture, "Disc Title: {0}\r\n", BDROM.DiscTitle);
                }

                summary += string.Format(CultureInfo.InvariantCulture, "Disc Label: {0}\r\n", BDROM.VolumeLabel);

                summary += string.Format(CultureInfo.InvariantCulture, "Disc Size: {0:N0} bytes\r\n", BDROM.Size);

                summary += string.Format(CultureInfo.InvariantCulture, "Protection: {0}\r\n", protection);

                summary += string.Format(CultureInfo.InvariantCulture, "Playlist: {0}\r\n", title);

                summary += string.Format(CultureInfo.InvariantCulture, "Size: {0:N0} bytes\r\n", totalSize);

                summary += string.Format(CultureInfo.InvariantCulture, "Length: {0}\r\n", totalLength);

                summary += string.Format(CultureInfo.InvariantCulture, "Total Bitrate: {0} Mbps\r\n", totalBitrate);

                if (playlist.HasHiddenTracks)
                {
                    report.Append("\r\n(*) Indicates included stream hidden by this playlist.\r\n");
                }

                if (playlist.VideoStreams.Count > 0)
                {
                    report.Append("\r\n");
                    report.Append("VIDEO:\r\n");
                    report.Append("\r\n");
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1,-20}{2,-16}\r\n", "Codec", "Bitrate", "Description"));
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1,-20}{2,-16}\r\n", "-----", "-------", "-----------"));

                    foreach (var stream in playlist.SortedStreams)
                    {
                        if (!stream.IsVideoStream)
                        {
                            continue;
                        }

                        var streamName = stream.CodecName;
                        if (stream.AngleIndex > 0)
                        {
                            streamName += string.Format(CultureInfo.InvariantCulture, " ({0})", stream.AngleIndex);
                        }

                        var streamBitrate = string.Format(CultureInfo.InvariantCulture, "{0:D}", (int)Math.Round((double)stream.BitRate / 1000));
                        if (stream.AngleIndex > 0)
                        {
                            streamBitrate += string.Format(CultureInfo.InvariantCulture, " ({0:D})", (int)Math.Round((double)stream.ActiveBitRate / 1000));
                        }
                        streamBitrate += " kbps";

                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-24}{1,-20}{2,-16}\r\n", (stream.IsHidden ? "* " : "") + streamName,
                                                    streamBitrate, stream.Description));

                        summary += string.Format(CultureInfo.InvariantCulture, (stream.IsHidden ? "* " : "") + "Video: {0} / {1} / {2}\r\n", streamName,
                                                 streamBitrate, stream.Description);
                    }
                }

                if (playlist.AudioStreams.Count > 0)
                {
                    report.Append("\r\n");
                    report.Append("AUDIO:\r\n");
                    report.Append("\r\n");
                    report.Append(string.Format(CultureInfo.InvariantCulture,
                                                "{0,-32}{1,-16}{2,-16}{3,-16}\r\n", "Codec", "Language", "Bitrate", "Description"));
                    report.Append(string.Format(CultureInfo.InvariantCulture,
                                                "{0,-32}{1,-16}{2,-16}{3,-16}\r\n", "-----", "--------", "-------", "-----------"));

                    foreach (var stream in playlist.SortedStreams)
                    {
                        if (!stream.IsAudioStream)
                        {
                            continue;
                        }

                        var streamBitrate = string.Format(CultureInfo.InvariantCulture, "{0:D} kbps", (int)Math.Round((double)stream.BitRate / 1000));

                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                                                    (stream.IsHidden ? "* " : "") + stream.CodecName, stream.LanguageName, streamBitrate, stream.Description));

                        summary += string.Format((stream.IsHidden ? "* " : "") + "Audio: {0} / {1} / {2}\r\n", stream.LanguageName, stream.CodecName,
                                                 stream.Description);
                    }
                }

                if (playlist.GraphicsStreams.Count > 0)
                {
                    report.Append("\r\n");
                    report.Append("SUBTITLES:\r\n");
                    report.Append("\r\n");
                    report.Append(string.Format(CultureInfo.InvariantCulture,
                                                "{0,-32}{1,-16}{2,-16}{3,-16}\r\n", "Codec", "Language", "Bitrate", "Description"));
                    report.Append(string.Format(CultureInfo.InvariantCulture,
                                                "{0,-32}{1,-16}{2,-16}{3,-16}\r\n", "-----", "--------", "-------", "-----------"));

                    foreach (var stream in playlist.SortedStreams)
                    {
                        if (!stream.IsGraphicsStream)
                        {
                            continue;
                        }

                        var streamBitrate = string.Format(CultureInfo.InvariantCulture, "{0:F3} kbps", (double)stream.BitRate / 1000);

                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                                                    (stream.IsHidden ? "* " : "") + stream.CodecName, stream.LanguageName, streamBitrate, stream.Description));

                        summary += string.Format(CultureInfo.InvariantCulture, (stream.IsHidden ? "* " : "") + "Subtitle: {0} / {1}\r\n", stream.LanguageName,
                                                 streamBitrate, stream.Description);
                    }
                }

                if (playlist.TextStreams.Count > 0)
                {
                    report.Append("\r\n");
                    report.Append("TEXT:\r\n");
                    report.Append("\r\n");
                    report.Append(string.Format(CultureInfo.InvariantCulture,
                                                "{0,-32}{1,-16}{2,-16}{3,-16}\r\n", "Codec", "Language", "Bitrate", "Description"));
                    report.Append(string.Format(CultureInfo.InvariantCulture,
                                                "{0,-32}{1,-16}{2,-16}{3,-16}\r\n", "-----", "--------", "-------", "-----------"));

                    foreach (var stream in playlist.SortedStreams)
                    {
                        if (!stream.IsTextStream)
                        {
                            continue;
                        }

                        var streamBitrate = string.Format(CultureInfo.InvariantCulture, "{0:F3} kbps", (double)stream.BitRate / 1000);

                        report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                                                    (stream.IsHidden ? "* " : "") + stream.CodecName, stream.LanguageName, streamBitrate, stream.Description));
                    }
                }

                report.Append("\r\n");
                report.Append("FILES:\r\n");
                report.Append("\r\n");
                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}\r\n", "Name", "Time In", "Length", "Size",
                                            "Total Bitrate"));
                report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}\r\n", "----", "-------", "------", "----",
                                            "-------------"));

                foreach (var clip in playlist.StreamClips)
                {
                    var clipName = clip.DisplayName;

                    if (clip.AngleIndex > 0)
                    {
                        clipName += string.Format(CultureInfo.InvariantCulture, " ({0})", clip.AngleIndex);
                    }

                    var clipSize = string.Format(CultureInfo.InvariantCulture, "{0:N0}", clip.PacketSize);

                    var clipInSpan     = new TimeSpan((long)(clip.RelativeTimeIn * 10000000));
                    var clipOutSpan    = new TimeSpan((long)(clip.RelativeTimeOut * 10000000));
                    var clipLengthSpan = new TimeSpan((long)(clip.Length * 10000000));

                    var clipTimeIn = string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", clipInSpan.Hours, clipInSpan.Minutes,
                                                   clipInSpan.Seconds, clipInSpan.Milliseconds);
                    var clipLength = string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", clipLengthSpan.Hours, clipLengthSpan.Minutes,
                                                   clipLengthSpan.Seconds, clipLengthSpan.Milliseconds);

                    var clipBitrate = Math.Round((double)clip.PacketBitRate / 1000).ToString("N0", CultureInfo.InvariantCulture);

                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}\r\n", clipName, clipTimeIn, clipLength,
                                                clipSize, clipBitrate));
                }

                report.Append("\r\n");
                report.Append("CHAPTERS:\r\n");
                report.Append("\r\n");
                report.Append(string.Format(CultureInfo.InvariantCulture,
                                            "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}{5,-16}{6,-16}{7,-16}{8,-16}{9,-16}{10,-16}{11,-16}{12,-16}\r\n", "Number", "Time In", "Length",
                                            "Avg Video Rate", "Max 1-Sec Rate", "Max 1-Sec Time", "Max 5-Sec Rate", "Max 5-Sec Time", "Max 10Sec Rate", "Max 10Sec Time",
                                            "Avg Frame Size", "Max Frame Size", "Max Frame Time"));
                report.Append(string.Format(CultureInfo.InvariantCulture,
                                            "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}{5,-16}{6,-16}{7,-16}{8,-16}{9,-16}{10,-16}{11,-16}{12,-16}\r\n", "------", "-------", "------",
                                            "--------------", "--------------", "--------------", "--------------", "--------------", "--------------", "--------------",
                                            "--------------", "--------------", "--------------"));

                var    window1Bits         = new Queue <double>();
                var    window1Seconds      = new Queue <double>();
                double window1BitsSum      = 0;
                double window1SecondsSum   = 0;
                double window1PeakBitrate  = 0;
                double window1PeakLocation = 0;

                var    window5Bits         = new Queue <double>();
                var    window5Seconds      = new Queue <double>();
                double window5BitsSum      = 0;
                double window5SecondsSum   = 0;
                double window5PeakBitrate  = 0;
                double window5PeakLocation = 0;

                var    window10Bits         = new Queue <double>();
                var    window10Seconds      = new Queue <double>();
                double window10BitsSum      = 0;
                double window10SecondsSum   = 0;
                double window10PeakBitrate  = 0;
                double window10PeakLocation = 0;

                double chapterPosition         = 0;
                double chapterBits             = 0;
                long   chapterFrameCount       = 0;
                double chapterSeconds          = 0;
                double chapterMaxFrameSize     = 0;
                double chapterMaxFrameLocation = 0;

                var diagPID = playlist.VideoStreams[0].PID;

                var chapterIndex = 0;
                var clipIndex    = 0;
                var diagIndex    = 0;

                while (chapterIndex < playlist.Chapters.Count)
                {
                    TSStreamClip clip = null;
                    TSStreamFile file = null;

                    if (clipIndex < playlist.StreamClips.Count)
                    {
                        clip = playlist.StreamClips[clipIndex];
                        file = clip.StreamFile;
                    }

                    var    chapterStart = playlist.Chapters[chapterIndex];
                    double chapterEnd;
                    if (chapterIndex < playlist.Chapters.Count - 1)
                    {
                        chapterEnd = playlist.Chapters[chapterIndex + 1];
                    }
                    else
                    {
                        chapterEnd = playlist.TotalLength;
                    }
                    var chapterLength = chapterEnd - chapterStart;

                    List <TSStreamDiagnostics> diagList = null;

                    if (clip != null && clip.AngleIndex == 0 && file != null && file.StreamDiagnostics.ContainsKey(diagPID))
                    {
                        diagList = file.StreamDiagnostics[diagPID];

                        while (diagIndex < diagList.Count && chapterPosition < chapterEnd)
                        {
                            var diag = diagList[diagIndex++];

                            if (diag.Marker < clip.TimeIn)
                            {
                                continue;
                            }

                            chapterPosition = diag.Marker - clip.TimeIn + clip.RelativeTimeIn;

                            var seconds = diag.Interval;
                            var bits    = diag.Bytes * 8.0;

                            chapterBits    += bits;
                            chapterSeconds += seconds;

                            if (diag.Tag != null)
                            {
                                chapterFrameCount++;
                            }

                            window1SecondsSum += seconds;
                            window1Seconds.Enqueue(seconds);
                            window1BitsSum += bits;
                            window1Bits.Enqueue(bits);

                            window5SecondsSum += diag.Interval;
                            window5Seconds.Enqueue(diag.Interval);
                            window5BitsSum += bits;
                            window5Bits.Enqueue(bits);

                            window10SecondsSum += seconds;
                            window10Seconds.Enqueue(seconds);
                            window10BitsSum += bits;
                            window10Bits.Enqueue(bits);

                            if (bits > chapterMaxFrameSize * 8)
                            {
                                chapterMaxFrameSize     = bits / 8;
                                chapterMaxFrameLocation = chapterPosition;
                            }

                            if (window1SecondsSum > 1.0)
                            {
                                var bitrate = window1BitsSum / window1SecondsSum;
                                if (bitrate > window1PeakBitrate && chapterPosition - window1SecondsSum > 0)
                                {
                                    window1PeakBitrate  = bitrate;
                                    window1PeakLocation = chapterPosition - window1SecondsSum;
                                }

                                window1BitsSum    -= window1Bits.Dequeue();
                                window1SecondsSum -= window1Seconds.Dequeue();
                            }

                            if (window5SecondsSum > 5.0)
                            {
                                var bitrate = window5BitsSum / window5SecondsSum;
                                if (bitrate > window5PeakBitrate && chapterPosition - window5SecondsSum > 0)
                                {
                                    window5PeakBitrate  = bitrate;
                                    window5PeakLocation = chapterPosition - window5SecondsSum;
                                    if (window5PeakLocation < 0)
                                    {
                                        window5PeakLocation = 0;
                                        window5PeakLocation = 0;
                                    }
                                }

                                window5BitsSum    -= window5Bits.Dequeue();
                                window5SecondsSum -= window5Seconds.Dequeue();
                            }

                            if (window10SecondsSum > 10.0)
                            {
                                var bitrate = window10BitsSum / window10SecondsSum;
                                if (bitrate > window10PeakBitrate && chapterPosition - window10SecondsSum > 0)
                                {
                                    window10PeakBitrate  = bitrate;
                                    window10PeakLocation = chapterPosition - window10SecondsSum;
                                }

                                window10BitsSum    -= window10Bits.Dequeue();
                                window10SecondsSum -= window10Seconds.Dequeue();
                            }
                        }
                    }

                    if (diagList == null || diagIndex == diagList.Count)
                    {
                        if (clipIndex < playlist.StreamClips.Count)
                        {
                            clipIndex++;
                            diagIndex = 0;
                        }
                        else
                        {
                            chapterPosition = chapterEnd;
                        }
                    }

                    if (chapterPosition >= chapterEnd)
                    {
                        ++chapterIndex;

                        var window1PeakSpan     = new TimeSpan((long)(window1PeakLocation * 10000000));
                        var window5PeakSpan     = new TimeSpan((long)(window5PeakLocation * 10000000));
                        var window10PeakSpan    = new TimeSpan((long)(window10PeakLocation * 10000000));
                        var chapterMaxFrameSpan = new TimeSpan((long)(chapterMaxFrameLocation * 10000000));
                        var chapterStartSpan    = new TimeSpan((long)(chapterStart * 10000000));
                        var chapterEndSpan      = new TimeSpan((long)(chapterEnd * 10000000));
                        var chapterLengthSpan   = new TimeSpan((long)(chapterLength * 10000000));

                        double chapterBitrate = 0;
                        if (chapterLength > 0)
                        {
                            chapterBitrate = chapterBits / chapterLength;
                        }
                        double chapterAvgFrameSize = 0;
                        if (chapterFrameCount > 0)
                        {
                            chapterAvgFrameSize = chapterBits / chapterFrameCount / 8;
                        }

                        report.Append(string.Format(CultureInfo.InvariantCulture,
                                                    "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}{5,-16}{6,-16}{7,-16}{8,-16}{9,-16}{10,-16}{11,-16}{12,-16}\r\n", chapterIndex,
                                                    string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", chapterStartSpan.Hours, chapterStartSpan.Minutes,
                                                                  chapterStartSpan.Seconds, chapterStartSpan.Milliseconds),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:D1}:{1:D2}:{2:D2}.{3:D3}", chapterLengthSpan.Hours, chapterLengthSpan.Minutes,
                                                                  chapterLengthSpan.Seconds, chapterLengthSpan.Milliseconds),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:N0} kbps", Math.Round(chapterBitrate / 1000)),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:N0} kbps", Math.Round(window1PeakBitrate / 1000)),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:D2}:{1:D2}:{2:D2}.{3:D3}", window1PeakSpan.Hours, window1PeakSpan.Minutes,
                                                                  window1PeakSpan.Seconds, window1PeakSpan.Milliseconds),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:N0} kbps", Math.Round(window5PeakBitrate / 1000)),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:D2}:{1:D2}:{2:D2}.{3:D3}", window5PeakSpan.Hours, window5PeakSpan.Minutes,
                                                                  window5PeakSpan.Seconds, window5PeakSpan.Milliseconds),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:N0} kbps", Math.Round(window10PeakBitrate / 1000)),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:D2}:{1:D2}:{2:D2}.{3:D3}", window10PeakSpan.Hours, window10PeakSpan.Minutes,
                                                                  window10PeakSpan.Seconds, window10PeakSpan.Milliseconds),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:N0} bytes", chapterAvgFrameSize),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:N0} bytes", chapterMaxFrameSize),
                                                    string.Format(CultureInfo.InvariantCulture, "{0:D2}:{1:D2}:{2:D2}.{3:D3}", chapterMaxFrameSpan.Hours, chapterMaxFrameSpan.Minutes,
                                                                  chapterMaxFrameSpan.Seconds, chapterMaxFrameSpan.Milliseconds)));

                        window1Bits         = new Queue <double>();
                        window1Seconds      = new Queue <double>();
                        window1BitsSum      = 0;
                        window1SecondsSum   = 0;
                        window1PeakBitrate  = 0;
                        window1PeakLocation = 0;

                        window5Bits         = new Queue <double>();
                        window5Seconds      = new Queue <double>();
                        window5BitsSum      = 0;
                        window5SecondsSum   = 0;
                        window5PeakBitrate  = 0;
                        window5PeakLocation = 0;

                        window10Bits         = new Queue <double>();
                        window10Seconds      = new Queue <double>();
                        window10BitsSum      = 0;
                        window10SecondsSum   = 0;
                        window10PeakBitrate  = 0;
                        window10PeakLocation = 0;

                        chapterBits             = 0;
                        chapterSeconds          = 0;
                        chapterFrameCount       = 0;
                        chapterMaxFrameSize     = 0;
                        chapterMaxFrameLocation = 0;
                    }
                }

                if (BDInfoSettings.GenerateStreamDiagnostics)
                {
                    report.Append("\r\n");
                    report.Append("STREAM DIAGNOSTICS:\r\n");
                    report.Append("\r\n");
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1,-16}{2,-16}{3,-16}{4,-24}{5,-24}{6,-24}{7,-16}{8,-16}\r\n", "File",
                                                "PID", "Type", "Codec", "Language", "Seconds", "Bitrate", "Bytes", "Packets"));
                    report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1,-16}{2,-16}{3,-16}{4,-24}{5,-24}{6,-24}{7,-16}{8,-16}\r\n", "----",
                                                "---", "----", "-----", "--------", "--------------", "--------------", "-------------", "-----", "-------"));

                    var reportedClips = new Dictionary <string, TSStreamClip>();
                    foreach (var clip in playlist.StreamClips)
                    {
                        if (clip.StreamFile == null)
                        {
                            continue;
                        }
                        if (reportedClips.ContainsKey(clip.Name))
                        {
                            continue;
                        }
                        reportedClips[clip.Name] = clip;

                        var clipName = clip.DisplayName;
                        if (clip.AngleIndex > 0)
                        {
                            clipName += string.Format(CultureInfo.InvariantCulture, " ({0})", clip.AngleIndex);
                        }
                        foreach (var clipStream in clip.StreamFile.Streams.Values)
                        {
                            if (!playlist.Streams.ContainsKey(clipStream.PID))
                            {
                                continue;
                            }

                            var playlistStream = playlist.Streams[clipStream.PID];

                            var clipBitRate = "0";
                            var clipSeconds = "0";

                            if (clip.StreamFile.Length > 0)
                            {
                                clipSeconds = clip.StreamFile.Length.ToString("F3", CultureInfo.InvariantCulture);
                                clipBitRate = Math.Round((double)clipStream.PayloadBytes * 8 / clip.StreamFile.Length / 1000)
                                              .ToString("N0", CultureInfo.InvariantCulture);
                            }

                            var language = "";
                            if (!string.IsNullOrEmpty(playlistStream.LanguageCode))
                            {
                                language = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", playlistStream.LanguageCode, playlistStream.LanguageName);
                            }

                            report.Append(string.Format(CultureInfo.InvariantCulture, "{0,-16}{1,-16}{2,-16}{3,-16}{4,-24}{5,-24}{6,-24}{7,-16}{8,-16}\r\n",
                                                        clipName, string.Format(CultureInfo.InvariantCulture, "{0} (0x{1:X})", clipStream.PID, clipStream.PID),
                                                        string.Format(CultureInfo.InvariantCulture, "0x{0:X2}", (byte)clipStream.StreamType), clipStream.CodecShortName, language,
                                                        clipSeconds, clipBitRate, clipStream.PayloadBytes.ToString("N0", CultureInfo.InvariantCulture),
                                                        clipStream.PacketCount.ToString("N0", CultureInfo.InvariantCulture)));
                        }
                    }
                }

                report.Append("\r\n");
                report.Append("[/code]\r\n");
                report.Append("<---- END FORUMS PASTE ---->\r\n");
                report.Append("\r\n");

                if (BDInfoSettings.GenerateTextSummary)
                {
                    report.Append("QUICK SUMMARY:\r\n\r\n");
                    report.Append(summary);
                    report.Append("\r\n");
                }
            }

            return(report.ToString());
        }
Ejemplo n.º 19
0
        //private BackgroundWorker InitBDROMWorker = null;
        public void InitBDROM(string path)
        {
            System.Console.WriteLine("Please wait while we scan the disc...");
            try
            {
                BDROM = new BDROM(path);
                BDROM.StreamClipFileScanError += new BDROM.OnStreamClipFileScanError(BDROM_StreamClipFileScanError);
                BDROM.StreamFileScanError += new BDROM.OnStreamFileScanError(BDROM_StreamFileScanError);
                BDROM.PlaylistFileScanError += new BDROM.OnPlaylistFileScanError(BDROM_PlaylistFileScanError);
                BDROM.Scan();

                System.Console.WriteLine(BDROM.DirectoryRoot.FullName);

                System.Console.WriteLine(string.Format("Detected BDMV Folder: {0} ({1})", BDROM.DirectoryBDMV.FullName, BDROM.VolumeLabel));

                List<string> features = new List<string>();
                if (BDROM.Is50Hz)
                {
                    features.Add("50Hz Content");
                }
                if (BDROM.IsBDPlus)
                {
                    features.Add("BD+ Copy Protection");
                }
                if (BDROM.IsBDJava)
                {
                    features.Add("BD-Java");
                }
                if (BDROM.Is3D)
                {
                    features.Add("Blu-ray 3D");
                }
                if (BDROM.IsDBOX)
                {
                    features.Add("D-BOX Motion Code");
                }
                if (BDROM.IsPSP)
                {
                    features.Add("PSP Digital Copy");
                }
                if (features.Count > 0)
                {
                    System.Console.WriteLine("Detected Features: " + string.Join(", ", features.ToArray()));
                }

                System.Console.WriteLine(string.Format("Disc Size: {0:N0} bytes{1}", BDROM.Size, Environment.NewLine));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 20
0
        public void Generate(
            BDROM BDROM,
            List <TSPlaylistFile> playlists,
            ScanBDROMResult scanResult)
        {
            Playlists = playlists;

            StreamWriter reportFile = null;

            if (BDInfoSettings.AutosaveReport)
            {
                string reportName = string.Format(
                    "BDINFO.{0}.txt",
                    BDROM.VolumeLabel);

                reportFile = File.CreateText(Path.Combine(Environment.CurrentDirectory, reportName));
            }
            textBoxReport.Text = "";

            string protection = (BDROM.IsBDPlus ? "BD+" : "AACS");
            string bdjava     = (BDROM.IsBDJava ? "Yes" : "No");

            List <string> extraFeatures = new List <string>();

            if (BDROM.Is50Hz)
            {
                extraFeatures.Add("50Hz Content");
            }
            if (BDROM.Is3D)
            {
                extraFeatures.Add("Blu-ray 3D");
            }
            if (BDROM.IsDBOX)
            {
                extraFeatures.Add("D-BOX Motion Code");
            }
            if (BDROM.IsPSP)
            {
                extraFeatures.Add("PSP Digital Copy");
            }
            if (extraFeatures.Count > 0)
            {
                report += string.Format(
                    "{0,-16}{1}\r\n", "Extras:", string.Join(", ", extraFeatures.ToArray()));
            }

            if (scanResult.ScanException != null)
            {
                report += string.Format(
                    "WARNING: Report is incomplete because: {0}\r\n",
                    scanResult.ScanException.Message);
            }
            if (scanResult.FileExceptions.Count > 0)
            {
                report += "WARNING: File errors were encountered during scan:\r\n";
                foreach (string fileName in scanResult.FileExceptions.Keys)
                {
                    Exception fileException = scanResult.FileExceptions[fileName];
                    report += string.Format(
                        "\r\n{0}\t{1}\r\n", fileName, fileException.Message);
                    report += string.Format(
                        "{0}\r\n", fileException.StackTrace);
                }
            }

            foreach (TSPlaylistFile playlist in playlists)
            {
                string summary = "";

                comboBoxPlaylist.Items.Add(playlist);

                string title    = playlist.Name;
                string discSize = string.Format(
                    "{0:N0}", BDROM.Size);

                TimeSpan playlistTotalLength =
                    new TimeSpan((long)(playlist.TotalLength * 10000000));
                string totalLength = string.Format(
                    "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                    playlistTotalLength.Hours,
                    playlistTotalLength.Minutes,
                    playlistTotalLength.Seconds,
                    playlistTotalLength.Milliseconds);
                string totalLengthShort = string.Format(
                    "{0:D1}:{1:D2}:{2:D2}",
                    playlistTotalLength.Hours,
                    playlistTotalLength.Minutes,
                    playlistTotalLength.Seconds);
                string totalSize = string.Format(
                    "{0:N0}", playlist.TotalSize);
                string totalBitrate = string.Format(
                    "{0:F2}",
                    Math.Round((double)playlist.TotalBitRate / 10000) / 100);

                TimeSpan playlistAngleLength =
                    new TimeSpan((long)(playlist.TotalAngleLength * 10000000));
                string totalAngleLength = string.Format(
                    "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                    playlistAngleLength.Hours,
                    playlistAngleLength.Minutes,
                    playlistAngleLength.Seconds,
                    playlistAngleLength.Milliseconds);
                string totalAngleSize = string.Format(
                    "{0:N0}", playlist.TotalAngleSize);
                string totalAngleBitrate = string.Format(
                    "{0:F2}",
                    Math.Round((double)playlist.TotalAngleBitRate / 10000) / 100);

                List <string> angleLengths       = new List <string>();
                List <string> angleSizes         = new List <string>();
                List <string> angleBitrates      = new List <string>();
                List <string> angleTotalLengths  = new List <string>();
                List <string> angleTotalSizes    = new List <string>();
                List <string> angleTotalBitrates = new List <string>();
                if (playlist.AngleCount > 0)
                {
                    for (int angleIndex = 0; angleIndex < playlist.AngleCount; angleIndex++)
                    {
                        double angleLength    = 0;
                        ulong  angleSize      = 0;
                        ulong  angleTotalSize = 0;
                        if (angleIndex < playlist.AngleClips.Count &&
                            playlist.AngleClips[angleIndex] != null)
                        {
                            foreach (TSStreamClip clip in playlist.AngleClips[angleIndex].Values)
                            {
                                angleTotalSize += clip.PacketSize;
                                if (clip.AngleIndex == angleIndex + 1)
                                {
                                    angleSize   += clip.PacketSize;
                                    angleLength += clip.Length;
                                }
                            }
                        }

                        angleSizes.Add(string.Format(
                                           "{0:N0}", angleSize));

                        TimeSpan angleTimeSpan =
                            new TimeSpan((long)(angleLength * 10000000));

                        angleLengths.Add(string.Format(
                                             "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                                             angleTimeSpan.Hours,
                                             angleTimeSpan.Minutes,
                                             angleTimeSpan.Seconds,
                                             angleTimeSpan.Milliseconds));

                        angleTotalSizes.Add(string.Format(
                                                "{0:N0}", angleTotalSize));

                        angleTotalLengths.Add(totalLength);

                        double angleBitrate = 0;
                        if (angleLength > 0)
                        {
                            angleBitrate = Math.Round((double)(angleSize * 8) / angleLength / 10000) / 100;
                        }
                        angleBitrates.Add(string.Format("{0:F2}", angleBitrate));

                        double angleTotalBitrate = 0;
                        if (playlist.TotalLength > 0)
                        {
                            angleTotalBitrate = Math.Round((double)(angleTotalSize * 8) / playlist.TotalLength / 10000) / 100;
                        }
                        angleTotalBitrates.Add(string.Format(
                                                   "{0:F2}", angleTotalBitrate));
                    }
                }

                string videoCodec   = "";
                string videoBitrate = "";
                if (playlist.VideoStreams.Count > 0)
                {
                    TSStream videoStream = playlist.VideoStreams[0];
                    videoCodec   = videoStream.CodecAltName;
                    videoBitrate = string.Format(
                        "{0:F2}", Math.Round((double)videoStream.BitRate / 10000) / 100);
                }

                string audio1        = "";
                string languageCode1 = "";
                if (playlist.AudioStreams.Count > 0)
                {
                    TSAudioStream audioStream = playlist.AudioStreams[0];

                    languageCode1 = audioStream.LanguageCode;

                    audio1 = string.Format(
                        "{0} {1}",
                        audioStream.CodecAltName,
                        audioStream.ChannelDescription);

                    if (audioStream.BitRate > 0)
                    {
                        audio1 += string.Format(
                            " {0} Kbps",
                            (int)Math.Round((double)audioStream.BitRate / 1000));
                    }

                    if (audioStream.SampleRate > 0 &&
                        audioStream.BitDepth > 0)
                    {
                        audio1 += string.Format(
                            " ({0} kHz/{1}-bit)",
                            (int)Math.Round((double)audioStream.SampleRate / 1000),
                            audioStream.BitDepth);
                    }
                }

                string audio2 = "";
                if (playlist.AudioStreams.Count > 1)
                {
                    for (int i = 1; i < playlist.AudioStreams.Count; i++)
                    {
                        TSAudioStream audioStream = playlist.AudioStreams[i];

                        if (audioStream.LanguageCode == languageCode1 &&
                            audioStream.StreamType != TSStreamType.AC3_PLUS_SECONDARY_AUDIO &&
                            audioStream.StreamType != TSStreamType.DTS_HD_SECONDARY_AUDIO &&
                            !(audioStream.StreamType == TSStreamType.AC3_AUDIO &&
                              audioStream.ChannelCount == 2))
                        {
                            audio2 = string.Format(
                                "{0} {1}",
                                audioStream.CodecAltName, audioStream.ChannelDescription);

                            if (audioStream.BitRate > 0)
                            {
                                audio2 += string.Format(
                                    " {0} kbps",
                                    (int)Math.Round((double)audioStream.BitRate / 1000));
                            }

                            if (audioStream.SampleRate > 0 &&
                                audioStream.BitDepth > 0)
                            {
                                audio2 += string.Format(
                                    " ({0} kHz/{1}-bit)",
                                    (int)Math.Round((double)audioStream.SampleRate / 1000),
                                    audioStream.BitDepth);
                            }
                            break;
                        }
                    }
                }

                report += "DISC INFO:\r\n";
                report += "\r\n";

                report += string.Format(
                    "{0,-16}{1}\r\n", "Disc Title:", BDROM.VolumeLabel);
                report += string.Format(
                    "{0,-16}{1:N0} bytes\r\n", "Disc Size:", BDROM.Size);
                report += string.Format(
                    "{0,-16}{1}\r\n", "Protection:", protection);
                report += string.Format(
                    "{0,-16}{1}\r\n", "BD-Java:", bdjava);
                if (extraFeatures.Count > 0)
                {
                    report += string.Format(
                        "{0,-16}{1}\r\n", "Extras:", string.Join(", ", extraFeatures.ToArray()));
                }
                report += string.Format(
                    "{0,-16}{1}\r\n", "TDMaker:", Application.ProductVersion + " (BDInfo 0.5.8)");

                report += "\r\n";
                report += "PLAYLIST REPORT:\r\n";
                report += "\r\n";
                report += string.Format(
                    "{0,-24}{1}\r\n", "Name:", title);
                report += string.Format(
                    "{0,-24}{1} (h:m:s.ms)\r\n", "Length:", totalLength);
                report += string.Format(
                    "{0,-24}{1:N0} bytes\r\n", "Size:", totalSize);
                report += string.Format(
                    "{0,-24}{1} Mbps\r\n", "Total Bitrate:", totalBitrate);
                if (playlist.AngleCount > 0)
                {
                    for (int angleIndex = 0; angleIndex < playlist.AngleCount; angleIndex++)
                    {
                        report += "\r\n";
                        report += string.Format(
                            "{0,-24}{1} (h:m:s.ms) / {2} (h:m:s.ms)\r\n", string.Format("Angle {0} Length:", angleIndex + 1),
                            angleLengths[angleIndex], angleTotalLengths[angleIndex]);
                        report += string.Format(
                            "{0,-24}{1:N0} bytes / {2:N0} bytes\r\n", string.Format("Angle {0} Size:", angleIndex + 1),
                            angleSizes[angleIndex], angleTotalSizes[angleIndex]);
                        report += string.Format(
                            "{0,-24}{1} Mbps / {2} Mbps\r\n", string.Format("Angle {0} Total Bitrate:", angleIndex + 1),
                            angleBitrates[angleIndex], angleTotalBitrates[angleIndex], angleIndex);
                    }
                    report += "\r\n";
                    report += string.Format(
                        "{0,-24}{1} (h:m:s.ms)\r\n", "All Angles Length:", totalAngleLength);
                    report += string.Format(
                        "{0,-24}{1} bytes\r\n", "All Angles Size:", totalAngleSize);
                    report += string.Format(
                        "{0,-24}{1} Mbps\r\n", "All Angles Bitrate:", totalAngleBitrate);
                }

                /*
                 * report += string.Format(
                 *  "{0,-24}{1}\r\n", "Description:", "");
                 */

                summary += string.Format(
                    "Disc Title: {0}\r\n", BDROM.VolumeLabel);
                summary += string.Format(
                    "Disc Size: {0:N0} bytes\r\n", BDROM.Size);
                summary += string.Format(
                    "Protection: {0}\r\n", protection);
                summary += string.Format(
                    "BD-Java: {0}\r\n", bdjava);
                summary += string.Format(
                    "Playlist: {0}\r\n", title);
                summary += string.Format(
                    "Size: {0:N0} bytes\r\n", totalSize);
                summary += string.Format(
                    "Length: {0}\r\n", totalLength);
                summary += string.Format(
                    "Total Bitrate: {0} Mbps\r\n", totalBitrate);

                if (playlist.HasHiddenTracks)
                {
                    report += "\r\n(*) Indicates included stream hidden by this playlist.\r\n";
                }

                if (playlist.VideoStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "VIDEO:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-24}{1,-20}{2,-16}\r\n",
                        "Codec",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-24}{1,-20}{2,-16}\r\n",
                        "-----",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsVideoStream)
                        {
                            continue;
                        }

                        string streamName = stream.CodecName;
                        if (stream.AngleIndex > 0)
                        {
                            streamName += string.Format(
                                " ({0})", stream.AngleIndex);
                        }

                        string streamBitrate = string.Format(
                            "{0:D}",
                            (int)Math.Round((double)stream.BitRate / 1000));
                        if (stream.AngleIndex > 0)
                        {
                            streamBitrate += string.Format(
                                " ({0:D})",
                                (int)Math.Round((double)stream.ActiveBitRate / 1000));
                        }
                        streamBitrate += " kbps";

                        report += string.Format(
                            "{0,-24}{1,-20}{2,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + streamName,
                            streamBitrate,
                            stream.Description);

                        summary += string.Format(
                            (stream.IsHidden ? "* " : "") + "Video: {0} / {1} / {2}\r\n",
                            streamName,
                            streamBitrate,
                            stream.Description);
                    }
                }

                if (playlist.AudioStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "AUDIO:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "Codec",
                        "Language",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "-----",
                        "--------",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsAudioStream)
                        {
                            continue;
                        }

                        string streamBitrate = string.Format(
                            "{0:D} kbps",
                            (int)Math.Round((double)stream.BitRate / 1000));

                        report += string.Format(
                            "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + stream.CodecName,
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);

                        summary += string.Format(
                            (stream.IsHidden ? "* " : "") + "Audio: {0} / {1} / {2}\r\n",
                            stream.LanguageName,
                            stream.CodecName,
                            stream.Description);
                    }
                }

                if (playlist.GraphicsStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "SUBTITLES:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "Codec",
                        "Language",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "-----",
                        "--------",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsGraphicsStream)
                        {
                            continue;
                        }

                        string streamBitrate = string.Format(
                            "{0:F3} kbps",
                            (double)stream.BitRate / 1000);

                        report += string.Format(
                            "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + stream.CodecName,
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);

                        summary += string.Format(
                            (stream.IsHidden ? "* " : "") + "Subtitle: {0} / {1}\r\n",
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);
                    }
                }

                if (playlist.TextStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "TEXT:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "Codec",
                        "Language",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "-----",
                        "--------",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsTextStream)
                        {
                            continue;
                        }

                        string streamBitrate = string.Format(
                            "{0:F3} kbps",
                            (double)stream.BitRate / 1000);

                        report += string.Format(
                            "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + stream.CodecName,
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);
                    }
                }

                report += "\r\n";

                if (BDInfoSettings.AutosaveReport && reportFile != null)
                {
                    try { reportFile.Write(report); }
                    catch { }
                }
                textBoxReport.Text += report;

                GC.Collect();
            }

            if (BDInfoSettings.AutosaveReport && reportFile != null)
            {
                try { reportFile.Write(report); }
                catch { }
            }
            textBoxReport.Text += report;

            if (reportFile != null)
            {
                reportFile.Close();
            }

            textBoxReport.Select(0, 0);
            comboBoxPlaylist.SelectedIndex  = 0;
            comboBoxChartType.SelectedIndex = 0;
        }
Ejemplo n.º 21
0
        public TSPlaylistFile(
            BDROM bdrom,
            string name,
            IEnumerable<TSStreamClip> clips)
        {
            BDROM = bdrom;
            Name = name;
            FullName = Path.Combine(bdrom.DirectoryPLAYLIST.FullName, Name).ToUpper();
            IsCustom = true;

            foreach (var clip in clips)
            {
                var newClip = new TSStreamClip(clip.StreamFile, clip.StreamClipFile)
                                  {
                                      Name = clip.Name,
                                      TimeIn = clip.TimeIn,
                                      TimeOut = clip.TimeOut,
                                      RelativeTimeIn = TotalLength,
                                      AngleIndex = clip.AngleIndex
                                  };

                newClip.Length = newClip.TimeOut - newClip.TimeIn;
                newClip.RelativeTimeOut = newClip.RelativeTimeIn + newClip.Length;
                newClip.Chapters.Add(clip.TimeIn);

                StreamClips.Add(newClip);

                if (newClip.AngleIndex > AngleCount)
                {
                    AngleCount = newClip.AngleIndex;
                }
                if (newClip.AngleIndex == 0)
                {
                    Chapters.Add(newClip.RelativeTimeIn);
                }
            }

            LoadStreamClips();
            _isInitialized = true;
        }
Ejemplo n.º 22
0
        private void GetBDInfo()
        {
            string strChapters = Processing.GetResourceString("streamselect_chapters");
            string strVideo = Processing.GetResourceString("streamselect_video");
            string strAudio = Processing.GetResourceString("streamselect_audio");
            string strSubtitles = Processing.GetResourceString("streamselect_subtitles");

            string bdTitleFormat = Processing.GetResourceString("streamselect_bd_general");
            const string bdAudioFormat = "{5:g}: {0} ({1}) / {2} ({3}) / {4}";
            const string bdSubFormat = "{3:g}: {0} / {1} ({2}); {4}";

            _bdInfo = new BDROM(JobInfo.InputFile);
            _bdInfo.Scan();

            int longestClip = GetLongestBDPlaylist();

            int playlistIndex = 1;

            foreach (TSPlaylistFile item in _bdInfo.PlaylistFiles.Values)
            {
                if (!item.IsValid)
                {
                    playlistIndex++;
                    continue;
                }

                int streamIndex = 0;

                DateTime duration = new DateTime();

                duration = duration.AddSeconds(item.TotalLength);

                string treeRoot = string.Format(bdTitleFormat, playlistIndex, item.Name,
                                                duration.ToString("H:mm:ss.fff"));

                Dictionary<string, object> treeData = new Dictionary<string, object>
                    {
                        {
                            "Name",
                            Path.Combine(_bdInfo.DirectoryPLAYLIST.FullName,
                                         item.Name)
                        },
                        {"PlaylistIndex", playlistIndex}
                    };

                TreeNode root = new TreeNode
                    {
                        ID = _treeNodeID++,
                        Name = treeRoot,
                        Data = treeData,
                        Children = new List<TreeNode>(),
                        IsChecked = true,
                    };
                root.IsExpanded = root.IsChecked;
                _tree.Add(root);

                TreeNode chaptersTree = CreateNode(root, strChapters, null);
                TreeNode videoTree = CreateNode(root, strVideo, null);
                TreeNode audioTree = CreateNode(root, strAudio, null);
                TreeNode subTree = CreateNode(root, strSubtitles, null);

                List<TimeSpan> streamChapters = new List<TimeSpan>();
                if (item.Chapters.Count > 1)
                {
                    streamIndex++;

                    streamChapters.AddRange(item.Chapters.Select(TimeSpan.FromSeconds));

                    string chaptersFormat = string.Format("{0:0} {1}", streamChapters.Count, strChapters);

                    CreateNode(chaptersTree, chaptersFormat, streamChapters);
                }

                string videoDescStereo = string.Empty;
                int leftVideoStreamID = -1;
                foreach (TSVideoStream clip in item.VideoStreams)
                {
                    streamIndex++;
                    string videoCodec = clip.CodecName;
                    string videoCodecShort = clip.CodecShortName;
                    string videoDesc = clip.Description;

                    if ((clip.StreamType == TSStreamType.AVC_VIDEO) && (item.VideoStreams.Count > 1)
                        && (item.VideoStreams[0].PID == clip.PID)
                        && (item.VideoStreams[item.VideoStreams.Count - 1].StreamType == TSStreamType.MVC_VIDEO))
                    {
                        videoDescStereo = videoDesc;
                        videoCodec += " (left eye)";
                        leftVideoStreamID = streamIndex;
                    }
                    if ((clip.StreamType == TSStreamType.MVC_VIDEO) && (item.VideoStreams.Count > 1)
                        && (item.VideoStreams[item.VideoStreams.Count - 1].PID == clip.PID)
                        && (item.VideoStreams[0].StreamType == TSStreamType.AVC_VIDEO))
                    {
                        videoDesc = videoDescStereo;
                        videoCodec = "MPEG-4 MVC Video (right eye)";
                    }
                     /* */
                    string videoStreamFormat =  string.Format("{3:g}: {0} ({1}), {2}", videoCodec, videoCodecShort,
                                                                   videoDesc, streamIndex);
                    switch (clip.StreamType)
                    {
                        case TSStreamType.AVC_VIDEO:
                        case TSStreamType.MPEG2_VIDEO:
                        case TSStreamType.MPEG1_VIDEO:
                        case TSStreamType.VC1_VIDEO:
                            {
                                VideoInfo vid = new VideoInfo
                                    {
                                        StreamId = streamIndex,
                                        TrackId = playlistIndex,
                                        FPS = (float) clip.FrameRateEnumerator/clip.FrameRateDenominator,
                                        PicSize = (VideoFormat) clip.VideoFormat,
                                        Interlaced = clip.IsInterlaced,
                                        Format = clip.CodecShortName,
                                        DemuxStreamId = clip.PID,
                                        FrameCount = 0,
                                        Encoded = false,
                                        IsRawStream = false,
                                        StreamSize = 0,
                                        Length = item.TotalLength,
                                        FrameRateEnumerator = clip.FrameRateEnumerator,
                                        FrameRateDenominator = clip.FrameRateDenominator,
                                        Height = clip.Height
                                    };

                                Int32.TryParse(item.Name.Substring(0, item.Name.LastIndexOf('.')), NumberStyles.Number,
                                               AppSettings.CInfo, out vid.DemuxPlayList);

                                foreach (TSStreamClip streamClip in item.StreamClips)
                                    vid.DemuxStreamNames.Add(streamClip.StreamFile.FileInfo.FullName);

                                float mod;
                                switch (clip.AspectRatio)
                                {
                                    case TSAspectRatio.ASPECT_16_9:
                                        mod = (float) 1.777778;
                                        break;
                                    default:
                                        mod = (float) 1.333333;
                                        break;
                                }
                                vid.Width = (int) (vid.Height*mod);
                                vid.AspectRatio = mod;

                                CreateNode(videoTree, videoStreamFormat, vid);
                            }
                            break;
                        case TSStreamType.MVC_VIDEO:
                            {
                                StereoVideoInfo vid = new StereoVideoInfo
                                    {
                                        RightStreamId = streamIndex,
                                        LeftStreamId = leftVideoStreamID
                                    };
                                CreateNode(videoTree, videoStreamFormat, vid);
                            }
                            break;
                    }
                }

                foreach (TSAudioStream audio in item.AudioStreams)
                {
                    streamIndex++;
                    string audioCodec = audio.CodecName;
                    string audioCodecShort = audio.CodecShortName;
                    string audioDesc = audio.Description;
                    string audioLangCode = audio.LanguageCode;
                    string audioLanguage = audio.LanguageName;

                    string audioStreamFormat = string.Format(bdAudioFormat, audioCodec, audioCodecShort, audioLangCode,
                                                             audioLanguage, audioDesc, streamIndex);

                    AudioInfo aud = new AudioInfo
                        {
                            Format = audioCodecShort,
                            FormatProfile = string.Empty,
                            Id = streamIndex,
                            StreamId = streamIndex,
                            LangCode = audioLangCode,
                            TempFile = string.Empty,
                            OriginalId = streamIndex,
                            Delay = 0,
                            Bitrate = audio.BitRate,
                            DemuxStreamId = audio.PID,
                            SampleRate = audio.SampleRate,
                            ChannelCount = audio.ChannelCount + audio.LFE,
                            BitDepth = audio.BitDepth,
                            ShortLang = audio.LanguageCode,
                            StreamSize = 0,
                            Length = item.TotalLength,
                            IsHdStream = audio.CoreStream != null
                        };

                    CreateNode(audioTree, audioStreamFormat, aud);
                }

                foreach (TSTextStream sub in item.TextStreams)
                {
                    streamIndex++;
                    string subCodecShort = sub.CodecShortName;
                    string subDesc = sub.Description;
                    string subLangCode = sub.LanguageCode;
                    string subLanguage = sub.LanguageName;

                    string subStreamFormat = string.Format(bdSubFormat, subCodecShort, subLangCode, subLanguage,
                                                           streamIndex, subDesc);

                    SubtitleInfo subInfo = new SubtitleInfo
                        {
                            Id = streamIndex,
                            StreamId = streamIndex,
                            TempFile = string.Empty,
                            LangCode = subLangCode,
                            Format = subCodecShort,
                            Delay = 0,
                            DemuxStreamId = sub.PID,
                            StreamSize = 0
                        };

                    CreateNode(subTree, subStreamFormat, subInfo);
                }

                foreach (TSGraphicsStream sub in item.GraphicsStreams)
                {
                    streamIndex++;
                    string subCodecShort = sub.CodecShortName;
                    string subDesc = sub.Description;
                    string subLangCode = sub.LanguageCode;
                    string subLanguage = sub.LanguageName;

                    string subStreamFormat = string.Format(bdSubFormat, subCodecShort, subLangCode, subLanguage,
                                                           streamIndex, subDesc);

                    SubtitleInfo subInfo = new SubtitleInfo
                        {
                            Id = streamIndex,
                            StreamId = streamIndex,
                            TempFile = string.Empty,
                            LangCode = subLangCode,
                            Format = subCodecShort,
                            DemuxStreamId = sub.PID,
                            StreamSize = 0
                        };

                    CreateNode(subTree, subStreamFormat, subInfo);
                }
                playlistIndex++;
            }
            _defaultSelection = longestClip - 1;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets the disc info.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>BlurayDiscInfo.</returns>
        public BlurayDiscInfo GetDiscInfo(string path)
        {
            var bdrom = new BDROM(path);

            bdrom.Scan();

            // Get the longest playlist
            var playlist = bdrom.PlaylistFiles.Values.OrderByDescending(p => p.TotalLength).FirstOrDefault(p => p.IsValid);

            var outputStream = new BlurayDiscInfo
            {
                MediaStreams = new List<MediaStream>()
            };

            if (playlist == null)
            {
                return outputStream;
            }

            outputStream.Chapters = playlist.Chapters;

            outputStream.RunTimeTicks = TimeSpan.FromSeconds(playlist.TotalLength).Ticks;

            var mediaStreams = new List<MediaStream> { };

            foreach (var stream in playlist.SortedStreams)
            {
                var videoStream = stream as TSVideoStream;

                if (videoStream != null)
                {
                    AddVideoStream(mediaStreams, videoStream);
                    continue;
                }

                var audioStream = stream as TSAudioStream;

                if (audioStream != null)
                {
                    AddAudioStream(mediaStreams, audioStream);
                    continue;
                }

                var textStream = stream as TSTextStream;

                if (textStream != null)
                {
                    AddSubtitleStream(mediaStreams, textStream);
                    continue;
                }

                var graphicsStream = stream as TSGraphicsStream;

                if (graphicsStream != null)
                {
                    AddSubtitleStream(mediaStreams, graphicsStream);
                }
            }

            outputStream.MediaStreams = mediaStreams;

            outputStream.PlaylistName = playlist.Name;

            if (playlist.StreamClips != null && playlist.StreamClips.Any())
            {
                // Get the files in the playlist
                outputStream.Files = playlist.StreamClips.Select(i => i.StreamFile.Name).ToList();
            }

            return outputStream;
        }
Ejemplo n.º 24
0
        public void Generate(
            BDROM BDROM,
            List<TSPlaylistFile> playlists,
            ScanBDROMResult scanResult)
        {
            Playlists = playlists;

            StreamWriter reportFile = null;
            if (BDInfoSettings.AutosaveReport)
            {
                string reportName = string.Format(
                    "BDINFO.{0}.txt",
                    BDROM.VolumeLabel);

                reportFile = File.CreateText(Path.Combine(Environment.CurrentDirectory, reportName));
            }
            textBoxReport.Text = "";

            string protection = (BDROM.IsBDPlus ? "BD+" : "AACS");
            string bdjava = (BDROM.IsBDJava ? "Yes" : "No");

            report += string.Format(
                "{0,-16}{1}\r\n", "Disc Title:", BDROM.VolumeLabel);
            report += string.Format(
                "{0,-16}{1:N0} bytes\r\n", "Disc Size:", BDROM.Size);
            report += string.Format(
                "{0,-16}{1}\r\n", "Protection:", protection);
            report += string.Format(
                "{0,-16}{1}\r\n", "BD-Java:", bdjava);

            List<string> extraFeatures = new List<string>();
            if (BDROM.Is50Hz)
            {
                extraFeatures.Add("50Hz Content");
            }
            if (BDROM.Is3D)
            {
                extraFeatures.Add("Blu-ray 3D");
            }
            if (BDROM.IsDBOX)
            {
                extraFeatures.Add("D-BOX Motion Code");
            }
            if (BDROM.IsPSP)
            {
                extraFeatures.Add("PSP Digital Copy");
            }
            if (extraFeatures.Count > 0)
            {
                report += string.Format(
                    "{0,-16}{1}\r\n", "Extras:", string.Join(", ", extraFeatures.ToArray()));
            }
            report += string.Format(
                "{0,-16}{1}\r\n", "BDInfo:", Application.ProductVersion);

            report += "\r\n";
            report += string.Format(
                "{0,-16}{1}\r\n", "Notes:", "");
            report += "\r\n";
            report += "BDINFO HOME:\r\n";
            report += "  Cinema Squid\r\n";
            report += "    http://www.cinemasquid.com/blu-ray/tools/bdinfo\r\n";
            report += "\r\n";
            report += "INCLUDES FORUMS REPORT FOR:\r\n";
            report += "  AVS Forum Blu-ray Audio and Video Specifications Thread\r\n";
            report += "    http://www.avsforum.com/avs-vb/showthread.php?t=1155731\r\n";
            report += "\r\n";

            if (scanResult.ScanException != null)
            {
                report += string.Format(
                    "WARNING: Report is incomplete because: {0}\r\n",
                    scanResult.ScanException.Message);
            }
            if (scanResult.FileExceptions.Count > 0)
            {
                report += "WARNING: File errors were encountered during scan:\r\n";
                foreach (string fileName in scanResult.FileExceptions.Keys)
                {
                    Exception fileException = scanResult.FileExceptions[fileName];
                    report += string.Format(
                        "\r\n{0}\t{1}\r\n", fileName, fileException.Message);
                    report += string.Format(
                        "{0}\r\n", fileException.StackTrace);
                }
            }

            foreach (TSPlaylistFile playlist in playlists)
            {
                string summary = "";

                comboBoxPlaylist.Items.Add(playlist);

                string title = playlist.Name;
                string discSize = string.Format(
                    "{0:N0}", BDROM.Size);

                TimeSpan playlistTotalLength =
                    new TimeSpan((long)(playlist.TotalLength * 10000000));
                string totalLength = string.Format(
                    "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                    playlistTotalLength.Hours,
                    playlistTotalLength.Minutes,
                    playlistTotalLength.Seconds,
                    playlistTotalLength.Milliseconds);
                string totalLengthShort = string.Format(
                    "{0:D1}:{1:D2}:{2:D2}",
                    playlistTotalLength.Hours,
                    playlistTotalLength.Minutes,
                    playlistTotalLength.Seconds);
                string totalSize = string.Format(
                    "{0:N0}", playlist.TotalSize);
                string totalBitrate = string.Format(
                    "{0:F2}",
                    Math.Round((double)playlist.TotalBitRate / 10000) / 100);

                TimeSpan playlistAngleLength =
                    new TimeSpan((long)(playlist.TotalAngleLength * 10000000));
                string totalAngleLength = string.Format(
                    "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                    playlistAngleLength.Hours,
                    playlistAngleLength.Minutes,
                    playlistAngleLength.Seconds,
                    playlistAngleLength.Milliseconds);
                string totalAngleSize = string.Format(
                    "{0:N0}", playlist.TotalAngleSize);
                string totalAngleBitrate = string.Format(
                    "{0:F2}",
                    Math.Round((double)playlist.TotalAngleBitRate / 10000) / 100);

                List<string> angleLengths = new List<string>();
                List<string> angleSizes = new List<string>();
                List<string> angleBitrates = new List<string>();
                List<string> angleTotalLengths = new List<string>();
                List<string> angleTotalSizes = new List<string>();
                List<string> angleTotalBitrates = new List<string>();
                if (playlist.AngleCount > 0)
                {
                    for (int angleIndex = 0; angleIndex < playlist.AngleCount; angleIndex++)
                    {
                        double angleLength = 0;
                        ulong angleSize = 0;
                        ulong angleTotalSize = 0;
                        if (angleIndex < playlist.AngleClips.Count &&
                            playlist.AngleClips[angleIndex] != null)
                        {
                            foreach (TSStreamClip clip in playlist.AngleClips[angleIndex].Values)
                            {
                                angleTotalSize += clip.PacketSize;
                                if (clip.AngleIndex == angleIndex + 1)
                                {
                                    angleSize += clip.PacketSize;
                                    angleLength += clip.Length;
                                }
                            }
                        }

                        angleSizes.Add(string.Format(
                            "{0:N0}", angleSize));

                        TimeSpan angleTimeSpan =
                            new TimeSpan((long)(angleLength * 10000000));

                        angleLengths.Add(string.Format(
                            "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                            angleTimeSpan.Hours,
                            angleTimeSpan.Minutes,
                            angleTimeSpan.Seconds,
                            angleTimeSpan.Milliseconds));

                        angleTotalSizes.Add(string.Format(
                            "{0:N0}", angleTotalSize));

                        angleTotalLengths.Add(totalLength);

                        double angleBitrate = 0;
                        if (angleLength > 0)
                        {
                            angleBitrate = Math.Round((double)(angleSize * 8) / angleLength / 10000) / 100;
                        }
                        angleBitrates.Add(string.Format("{0:F2}", angleBitrate));

                        double angleTotalBitrate = 0;
                        if (playlist.TotalLength > 0)
                        {
                            angleTotalBitrate = Math.Round((double)(angleTotalSize * 8) / playlist.TotalLength / 10000) / 100;
                        }
                        angleTotalBitrates.Add(string.Format(
                            "{0:F2}", angleTotalBitrate));
                    }
                }

                string videoCodec = "";
                string videoBitrate = "";
                if (playlist.VideoStreams.Count > 0)
                {
                    TSStream videoStream = playlist.VideoStreams[0];
                    videoCodec = videoStream.CodecAltName;
                    videoBitrate = string.Format(
                        "{0:F2}", Math.Round((double)videoStream.BitRate / 10000) / 100);
                }

                string audio1 = "";
                string languageCode1 = "";
                if (playlist.AudioStreams.Count > 0)
                {
                    TSAudioStream audioStream = playlist.AudioStreams[0];

                    languageCode1 = audioStream.LanguageCode;

                    audio1 = string.Format(
                        "{0} {1}",
                        audioStream.CodecAltName,
                        audioStream.ChannelDescription);

                    if (audioStream.BitRate > 0)
                    {
                        audio1 += string.Format(
                            " {0}Kbps",
                            (int)Math.Round((double)audioStream.BitRate / 1000));
                    }

                    if (audioStream.SampleRate > 0 &&
                        audioStream.BitDepth > 0)
                    {
                        audio1 += string.Format(
                            " ({0}kHz/{1}-bit)",
                            (int)Math.Round((double)audioStream.SampleRate / 1000),
                            audioStream.BitDepth);
                    }
                }

                string audio2 = "";
                if (playlist.AudioStreams.Count > 1)
                {
                    for (int i = 1; i < playlist.AudioStreams.Count; i++)
                    {
                        TSAudioStream audioStream = playlist.AudioStreams[i];

                        if (audioStream.LanguageCode == languageCode1 &&
                            audioStream.StreamType != TSStreamType.AC3_PLUS_SECONDARY_AUDIO &&
                            audioStream.StreamType != TSStreamType.DTS_HD_SECONDARY_AUDIO &&
                            !(audioStream.StreamType == TSStreamType.AC3_AUDIO &&
                              audioStream.ChannelCount == 2))
                        {
                            audio2 = string.Format(
                                "{0} {1}",
                                audioStream.CodecAltName, audioStream.ChannelDescription);

                            if (audioStream.BitRate > 0)
                            {
                                audio2 += string.Format(
                                    " {0}Kbps",
                                    (int)Math.Round((double)audioStream.BitRate / 1000));
                            }

                            if (audioStream.SampleRate > 0 &&
                                audioStream.BitDepth > 0)
                            {
                                audio2 += string.Format(
                                    " ({0}kHz/{1}-bit)",
                                    (int)Math.Round((double)audioStream.SampleRate / 1000),
                                    audioStream.BitDepth);
                            }
                            break;
                        }
                    }
                }

                report += "\r\n";
                report += "********************\r\n";
                report += "PLAYLIST: " + playlist.Name + "\r\n";
                report += "********************\r\n";
                report += "\r\n";
                report += "<--- BEGIN FORUMS PASTE --->\r\n";
                report += "[code]\r\n";

                report += string.Format(
                    "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "Total",
                    "Video",
                    "",
                    "");

                report += string.Format(
                    "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n",
                    "Title",
                    "Codec",
                    "Length",
                    "Movie Size",
                    "Disc Size",
                    "Bitrate",
                    "Bitrate",
                    "Main Audio Track",
                    "Secondary Audio Track");

                report += string.Format(
                    "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n",
                    "-----",
                    "------",
                    "-------",
                    "--------------",
                    "--------------",
                    "-------",
                    "-------",
                    "------------------",
                    "---------------------");

                report += string.Format(
                    "{0,-64}{1,-8}{2,-8}{3,-16}{4,-16}{5,-8}{6,-8}{7,-42}{8}\r\n",
                    title,
                    videoCodec,
                    totalLengthShort,
                    totalSize,
                    discSize,
                    totalBitrate,
                    videoBitrate,
                    audio1,
                    audio2);

                report += "[/code]\r\n";
                report += "\r\n";
                report += "[code]\r\n";

                report += "\r\n";
                report += "DISC INFO:\r\n";
                report += "\r\n";

                report += string.Format(
                    "{0,-16}{1}\r\n", "Disc Title:", BDROM.VolumeLabel);
                report += string.Format(
                    "{0,-16}{1:N0} bytes\r\n", "Disc Size:", BDROM.Size);
                report += string.Format(
                    "{0,-16}{1}\r\n", "Protection:", protection);
                report += string.Format(
                    "{0,-16}{1}\r\n", "BD-Java:", bdjava);
                if (extraFeatures.Count > 0)
                {
                    report += string.Format(
                        "{0,-16}{1}\r\n", "Extras:", string.Join(", ", extraFeatures.ToArray()));
                }
                report += string.Format(
                    "{0,-16}{1}\r\n", "BDInfo:", Application.ProductVersion);

                report += "\r\n";
                report += "PLAYLIST REPORT:\r\n";
                report += "\r\n";
                report += string.Format(
                    "{0,-24}{1}\r\n", "Name:", title);
                report += string.Format(
                    "{0,-24}{1} (h:m:s.ms)\r\n", "Length:", totalLength);
                report += string.Format(
                    "{0,-24}{1:N0} bytes\r\n", "Size:", totalSize);
                report += string.Format(
                    "{0,-24}{1} Mbps\r\n", "Total Bitrate:", totalBitrate);
                if (playlist.AngleCount > 0)
                {
                    for (int angleIndex = 0; angleIndex < playlist.AngleCount; angleIndex++)
                    {
                        report += "\r\n";
                        report += string.Format(
                            "{0,-24}{1} (h:m:s.ms) / {2} (h:m:s.ms)\r\n", string.Format("Angle {0} Length:", angleIndex + 1),
                            angleLengths[angleIndex], angleTotalLengths[angleIndex]);
                        report += string.Format(
                            "{0,-24}{1:N0} bytes / {2:N0} bytes\r\n", string.Format("Angle {0} Size:", angleIndex + 1),
                            angleSizes[angleIndex], angleTotalSizes[angleIndex]);
                        report += string.Format(
                            "{0,-24}{1} Mbps / {2} Mbps\r\n", string.Format("Angle {0} Total Bitrate:", angleIndex + 1),
                            angleBitrates[angleIndex], angleTotalBitrates[angleIndex], angleIndex);
                    }
                    report += "\r\n";
                    report += string.Format(
                        "{0,-24}{1} (h:m:s.ms)\r\n", "All Angles Length:", totalAngleLength);
                    report += string.Format(
                        "{0,-24}{1} bytes\r\n", "All Angles Size:", totalAngleSize);
                    report += string.Format(
                        "{0,-24}{1} Mbps\r\n", "All Angles Bitrate:", totalAngleBitrate);
                }
                /*
                report += string.Format(
                    "{0,-24}{1}\r\n", "Description:", "");
                 */

                summary += string.Format(
                    "Disc Title: {0}\r\n", BDROM.VolumeLabel);
                summary += string.Format(
                    "Disc Size: {0:N0} bytes\r\n", BDROM.Size);
                summary += string.Format(
                    "Protection: {0}\r\n", protection);
                summary += string.Format(
                    "BD-Java: {0}\r\n", bdjava);
                summary += string.Format(
                    "Playlist: {0}\r\n", title);
                summary += string.Format(
                    "Size: {0:N0} bytes\r\n", totalSize);
                summary += string.Format(
                    "Length: {0}\r\n", totalLength);
                summary += string.Format(
                    "Total Bitrate: {0} Mbps\r\n", totalBitrate);

                if (playlist.HasHiddenTracks)
                {
                    report += "\r\n(*) Indicates included stream hidden by this playlist.\r\n";
                }

                if (playlist.VideoStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "VIDEO:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-24}{1,-20}{2,-16}\r\n",
                        "Codec",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-24}{1,-20}{2,-16}\r\n",
                        "-----",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsVideoStream) continue;

                        string streamName = stream.CodecName;
                        if (stream.AngleIndex > 0)
                        {
                            streamName += string.Format(
                                " ({0})", stream.AngleIndex);
                        }

                        string streamBitrate = string.Format(
                            "{0:D}",
                            (int)Math.Round((double)stream.BitRate / 1000));
                        if (stream.AngleIndex > 0)
                        {
                            streamBitrate += string.Format(
                                " ({0:D})",
                                (int)Math.Round((double)stream.ActiveBitRate / 1000));
                        }
                        streamBitrate += " kbps";

                        report += string.Format(
                            "{0,-24}{1,-20}{2,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + streamName,
                            streamBitrate,
                            stream.Description);

                        summary += string.Format(
                            (stream.IsHidden ? "* " : "") + "Video: {0} / {1} / {2}\r\n",
                            streamName,
                            streamBitrate,
                            stream.Description);
                    }
                }

                if (playlist.AudioStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "AUDIO:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "Codec",
                        "Language",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                       "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "-----",
                        "--------",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsAudioStream) continue;

                        string streamBitrate = string.Format(
                            "{0:D} kbps",
                            (int)Math.Round((double)stream.BitRate / 1000));

                        report += string.Format(
                            "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + stream.CodecName,
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);

                        summary += string.Format(
                            (stream.IsHidden ? "* " : "") + "Audio: {0} / {1} / {2}\r\n",
                            stream.LanguageName,
                            stream.CodecName,
                            stream.Description);
                    }
                }

                if (playlist.GraphicsStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "SUBTITLES:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "Codec",
                        "Language",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "-----",
                        "--------",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsGraphicsStream) continue;

                        string streamBitrate = string.Format(
                            "{0:F3} kbps",
                            (double)stream.BitRate / 1000);

                        report += string.Format(
                            "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + stream.CodecName,
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);

                        summary += string.Format(
                            (stream.IsHidden ? "* " : "") + "Subtitle: {0} / {1}\r\n",
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);
                    }
                }

                if (playlist.TextStreams.Count > 0)
                {
                    report += "\r\n";
                    report += "TEXT:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "Codec",
                        "Language",
                        "Bitrate",
                        "Description");
                    report += string.Format(
                        "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                        "-----",
                        "--------",
                        "-------",
                        "-----------");

                    foreach (TSStream stream in playlist.SortedStreams)
                    {
                        if (!stream.IsTextStream) continue;

                        string streamBitrate = string.Format(
                            "{0:F3} kbps",
                            (double)stream.BitRate / 1000);

                        report += string.Format(
                            "{0,-32}{1,-16}{2,-16}{3,-16}\r\n",
                            (stream.IsHidden ? "* " : "") + stream.CodecName,
                            stream.LanguageName,
                            streamBitrate,
                            stream.Description);
                    }
                }

                report += "\r\n";
                report += "FILES:\r\n";
                report += "\r\n";
                report += string.Format(
                    "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}\r\n",
                    "Name",
                    "Time In",
                    "Length",
                    "Size",
                    "Total Bitrate");
                report += string.Format(
                    "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}\r\n",
                    "----",
                    "-------",
                    "------",
                    "----",
                    "-------------");

                foreach (TSStreamClip clip in playlist.StreamClips)
                {
                    string clipName = clip.DisplayName;

                    if (clip.AngleIndex > 0)
                    {
                        clipName += string.Format(
                            " ({0})", clip.AngleIndex);
                    }

                    string clipSize = string.Format(
                        "{0:N0}", clip.PacketSize);

                    TimeSpan clipInSpan =
                        new TimeSpan((long)(clip.RelativeTimeIn * 10000000));
                    TimeSpan clipOutSpan =
                        new TimeSpan((long)(clip.RelativeTimeOut * 10000000));
                    TimeSpan clipLengthSpan =
                        new TimeSpan((long)(clip.Length * 10000000));

                    string clipTimeIn = string.Format(
                        "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                        clipInSpan.Hours,
                        clipInSpan.Minutes,
                        clipInSpan.Seconds,
                        clipInSpan.Milliseconds);
                    string clipLength = string.Format(
                        "{0:D1}:{1:D2}:{2:D2}.{3:D3}",
                        clipLengthSpan.Hours,
                        clipLengthSpan.Minutes,
                        clipLengthSpan.Seconds,
                        clipLengthSpan.Milliseconds);

                    string clipBitrate = Math.Round(
                        (double)clip.PacketBitRate / 1000).ToString("N0");

                    report += string.Format(
                        "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}\r\n",
                        clipName,
                        clipTimeIn,
                        clipLength,
                        clipSize,
                        clipBitrate);
                }

                report += "\r\n";
                report += "CHAPTERS:\r\n";
                report += "\r\n";
                report += string.Format(
                    "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}{5,-16}{6,-16}{7,-16}{8,-16}{9,-16}{10,-16}{11,-16}{12,-16}\r\n",
                    "Number",
                    "Time In",
                    "Length",
                    "Avg Video Rate",
                    "Max 1-Sec Rate",
                    "Max 1-Sec Time",
                    "Max 5-Sec Rate",
                    "Max 5-Sec Time",
                    "Max 10Sec Rate",
                    "Max 10Sec Time",
                    "Avg Frame Size",
                    "Max Frame Size",
                    "Max Frame Time");
                report += string.Format(
                    "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}{5,-16}{6,-16}{7,-16}{8,-16}{9,-16}{10,-16}{11,-16}{12,-16}\r\n",
                    "------",
                    "-------",
                    "------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------",
                    "--------------");

                Queue<double> window1Bits = new Queue<double>();
                Queue<double> window1Seconds = new Queue<double>();
                double window1BitsSum = 0;
                double window1SecondsSum = 0;
                double window1PeakBitrate = 0;
                double window1PeakLocation = 0;

                Queue<double> window5Bits = new Queue<double>();
                Queue<double> window5Seconds = new Queue<double>();
                double window5BitsSum = 0;
                double window5SecondsSum = 0;
                double window5PeakBitrate = 0;
                double window5PeakLocation = 0;

                Queue<double> window10Bits = new Queue<double>();
                Queue<double> window10Seconds = new Queue<double>();
                double window10BitsSum = 0;
                double window10SecondsSum = 0;
                double window10PeakBitrate = 0;
                double window10PeakLocation = 0;

                double chapterPosition = 0;
                double chapterBits = 0;
                long chapterFrameCount = 0;
                double chapterSeconds = 0;
                double chapterMaxFrameSize = 0;
                double chapterMaxFrameLocation = 0;

                ushort diagPID = playlist.VideoStreams[0].PID;

                int chapterIndex = 0;
                int clipIndex = 0;
                int diagIndex = 0;

                while (chapterIndex < playlist.Chapters.Count)
                {
                    TSStreamClip clip = null;
                    TSStreamFile file = null;

                    if (clipIndex < playlist.StreamClips.Count)
                    {
                        clip = playlist.StreamClips[clipIndex];
                        file = clip.StreamFile;
                    }

                    double chapterStart = playlist.Chapters[chapterIndex];
                    double chapterEnd;
                    if (chapterIndex < playlist.Chapters.Count - 1)
                    {
                        chapterEnd = playlist.Chapters[chapterIndex + 1];
                    }
                    else
                    {
                        chapterEnd = playlist.TotalLength;
                    }
                    double chapterLength = chapterEnd - chapterStart;

                    List<TSStreamDiagnostics> diagList = null;

                    if (clip != null &&
                        clip.AngleIndex == 0 &&
                        file != null &&
                        file.StreamDiagnostics.ContainsKey(diagPID))
                    {
                        diagList = file.StreamDiagnostics[diagPID];

                        while (diagIndex < diagList.Count &&
                            chapterPosition < chapterEnd)
                        {
                            TSStreamDiagnostics diag = diagList[diagIndex++];

                            if (diag.Marker < clip.TimeIn) continue;

                            chapterPosition =
                                diag.Marker -
                                clip.TimeIn +
                                clip.RelativeTimeIn;

                            double seconds = diag.Interval;
                            double bits = diag.Bytes * 8.0;

                            chapterBits += bits;
                            chapterSeconds += seconds;

                            if (diag.Tag != null)
                            {
                                chapterFrameCount++;
                            }

                            window1SecondsSum += seconds;
                            window1Seconds.Enqueue(seconds);
                            window1BitsSum += bits;
                            window1Bits.Enqueue(bits);

                            window5SecondsSum += diag.Interval;
                            window5Seconds.Enqueue(diag.Interval);
                            window5BitsSum += bits;
                            window5Bits.Enqueue(bits);

                            window10SecondsSum += seconds;
                            window10Seconds.Enqueue(seconds);
                            window10BitsSum += bits;
                            window10Bits.Enqueue(bits);

                            if (bits > chapterMaxFrameSize * 8)
                            {
                                chapterMaxFrameSize = bits / 8;
                                chapterMaxFrameLocation = chapterPosition;
                            }
                            if (window1SecondsSum > 1.0)
                            {
                                double bitrate = window1BitsSum / window1SecondsSum;
                                if (bitrate > window1PeakBitrate &&
                                    chapterPosition - window1SecondsSum > 0)
                                {
                                    window1PeakBitrate = bitrate;
                                    window1PeakLocation = chapterPosition - window1SecondsSum;
                                }
                                window1BitsSum -= window1Bits.Dequeue();
                                window1SecondsSum -= window1Seconds.Dequeue();
                            }
                            if (window5SecondsSum > 5.0)
                            {
                                double bitrate = window5BitsSum / window5SecondsSum;
                                if (bitrate > window5PeakBitrate &&
                                    chapterPosition - window5SecondsSum > 0)
                                {
                                    window5PeakBitrate = bitrate;
                                    window5PeakLocation = chapterPosition - window5SecondsSum;
                                    if (window5PeakLocation < 0)
                                    {
                                        window5PeakLocation = 0;
                                        window5PeakLocation = 0;
                                    }
                                }
                                window5BitsSum -= window5Bits.Dequeue();
                                window5SecondsSum -= window5Seconds.Dequeue();
                            }
                            if (window10SecondsSum > 10.0)
                            {
                                double bitrate = window10BitsSum / window10SecondsSum;
                                if (bitrate > window10PeakBitrate &&
                                    chapterPosition - window10SecondsSum > 0)
                                {
                                    window10PeakBitrate = bitrate;
                                    window10PeakLocation = chapterPosition - window10SecondsSum;
                                }
                                window10BitsSum -= window10Bits.Dequeue();
                                window10SecondsSum -= window10Seconds.Dequeue();
                            }
                        }
                    }
                    if (diagList == null ||
                        diagIndex == diagList.Count)
                    {
                        if (clipIndex < playlist.StreamClips.Count)
                        {
                            clipIndex++; diagIndex = 0;
                        }
                        else
                        {
                            chapterPosition = chapterEnd;
                        }
                    }
                    if (chapterPosition >= chapterEnd)
                    {
                        ++chapterIndex;

                        TimeSpan window1PeakSpan = new TimeSpan((long)(window1PeakLocation * 10000000));
                        TimeSpan window5PeakSpan = new TimeSpan((long)(window5PeakLocation * 10000000));
                        TimeSpan window10PeakSpan = new TimeSpan((long)(window10PeakLocation * 10000000));
                        TimeSpan chapterMaxFrameSpan = new TimeSpan((long)(chapterMaxFrameLocation * 10000000));
                        TimeSpan chapterStartSpan = new TimeSpan((long)(chapterStart * 10000000));
                        TimeSpan chapterEndSpan = new TimeSpan((long)(chapterEnd * 10000000));
                        TimeSpan chapterLengthSpan = new TimeSpan((long)(chapterLength * 10000000));

                        double chapterBitrate = 0;
                        if (chapterLength > 0)
                        {
                            chapterBitrate = chapterBits / chapterLength;
                        }
                        double chapterAvgFrameSize = 0;
                        if (chapterFrameCount > 0)
                        {
                            chapterAvgFrameSize = chapterBits / chapterFrameCount / 8;
                        }

                        report += string.Format(
                            "{0,-16}{1,-16}{2,-16}{3,-16}{4,-16}{5,-16}{6,-16}{7,-16}{8,-16}{9,-16}{10,-16}{11,-16}{12,-16}\r\n",
                            chapterIndex,
                            string.Format("{0:D1}:{1:D2}:{2:D2}.{3:D3}", chapterStartSpan.Hours, chapterStartSpan.Minutes, chapterStartSpan.Seconds, chapterStartSpan.Milliseconds),
                            string.Format("{0:D1}:{1:D2}:{2:D2}.{3:D3}", chapterLengthSpan.Hours, chapterLengthSpan.Minutes, chapterLengthSpan.Seconds, chapterLengthSpan.Milliseconds),
                            string.Format("{0:N0} kbps", Math.Round(chapterBitrate / 1000)),
                            string.Format("{0:N0} kbps", Math.Round(window1PeakBitrate / 1000)),
                            string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", window1PeakSpan.Hours, window1PeakSpan.Minutes, window1PeakSpan.Seconds, window1PeakSpan.Milliseconds),
                            string.Format("{0:N0} kbps", Math.Round(window5PeakBitrate / 1000)),
                            string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", window5PeakSpan.Hours, window5PeakSpan.Minutes, window5PeakSpan.Seconds, window5PeakSpan.Milliseconds),
                            string.Format("{0:N0} kbps", Math.Round(window10PeakBitrate / 1000)),
                            string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", window10PeakSpan.Hours, window10PeakSpan.Minutes, window10PeakSpan.Seconds, window10PeakSpan.Milliseconds),
                            string.Format("{0:N0} bytes", chapterAvgFrameSize),
                            string.Format("{0:N0} bytes", chapterMaxFrameSize),
                            string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", chapterMaxFrameSpan.Hours, chapterMaxFrameSpan.Minutes, chapterMaxFrameSpan.Seconds, chapterMaxFrameSpan.Milliseconds));

                        window1Bits = new Queue<double>();
                        window1Seconds = new Queue<double>();
                        window1BitsSum = 0;
                        window1SecondsSum = 0;
                        window1PeakBitrate = 0;
                        window1PeakLocation = 0;

                        window5Bits = new Queue<double>();
                        window5Seconds = new Queue<double>();
                        window5BitsSum = 0;
                        window5SecondsSum = 0;
                        window5PeakBitrate = 0;
                        window5PeakLocation = 0;

                        window10Bits = new Queue<double>();
                        window10Seconds = new Queue<double>();
                        window10BitsSum = 0;
                        window10SecondsSum = 0;
                        window10PeakBitrate = 0;
                        window10PeakLocation = 0;

                        chapterBits = 0;
                        chapterSeconds = 0;
                        chapterFrameCount = 0;
                        chapterMaxFrameSize = 0;
                        chapterMaxFrameLocation = 0;
                    }
                }

                if (BDInfoSettings.GenerateStreamDiagnostics)
                {
                    report += "\r\n";
                    report += "STREAM DIAGNOSTICS:\r\n";
                    report += "\r\n";
                    report += string.Format(
                        "{0,-16}{1,-16}{2,-16}{3,-16}{4,-24}{5,-24}{6,-24}{7,-16}{8,-16}\r\n",
                        "File",
                        "PID",
                        "Type",
                        "Codec",
                        "Language",
                        "Seconds",
                        "Bitrate",
                        "Bytes",
                        "Packets");
                    report += string.Format(
                        "{0,-16}{1,-16}{2,-16}{3,-16}{4,-24}{5,-24}{6,-24}{7,-16}{8,-16}\r\n",
                        "----",
                        "---",
                        "----",
                        "-----",
                        "--------",
                        "--------------",
                        "--------------",
                        "-------------",
                        "-----",
                        "-------");

                    Dictionary<string, TSStreamClip> reportedClips = new Dictionary<string, TSStreamClip>();
                    foreach (TSStreamClip clip in playlist.StreamClips)
                    {
                        if (clip.StreamFile == null) continue;
                        if (reportedClips.ContainsKey(clip.Name)) continue;
                        reportedClips[clip.Name] = clip;

                        string clipName = clip.DisplayName;
                        if (clip.AngleIndex > 0)
                        {
                            clipName += string.Format(" ({0})", clip.AngleIndex);
                        }
                        foreach (TSStream clipStream in clip.StreamFile.Streams.Values)
                        {
                            if (!playlist.Streams.ContainsKey(clipStream.PID)) continue;

                            TSStream playlistStream =
                                playlist.Streams[clipStream.PID];

                            string clipBitRate = "0";
                            string clipSeconds = "0";

                            if (clip.StreamFile.Length > 0)
                            {
                                clipSeconds =
                                    clip.StreamFile.Length.ToString("F3");
                                clipBitRate = Math.Round(
                                     (double)clipStream.PayloadBytes * 8 /
                                     clip.StreamFile.Length / 1000).ToString("N0");
                            }
                            string language = "";
                            if (playlistStream.LanguageCode != null &&
                                playlistStream.LanguageCode.Length > 0)
                            {
                                language = string.Format(
                                    "{0} ({1})", playlistStream.LanguageCode, playlistStream.LanguageName);
                            }

                            report += string.Format(
                                "{0,-16}{1,-16}{2,-16}{3,-16}{4,-24}{5,-24}{6,-24}{7,-16}{8,-16}\r\n",
                                clipName,
                                string.Format("{0} (0x{1:X})", clipStream.PID, clipStream.PID),
                                string.Format("0x{0:X2}", (byte)clipStream.StreamType),
                                clipStream.CodecShortName,
                                language,
                                clipSeconds,
                                clipBitRate,
                                clipStream.PayloadBytes.ToString("N0"),
                                clipStream.PacketCount.ToString("N0"));
                        }
                    }
                }

                report += "\r\n";
                report += "[/code]\r\n";
                report += "<---- END FORUMS PASTE ---->\r\n";
                report += "\r\n";

                if (BDInfoSettings.GenerateTextSummary)
                {
                    report += "QUICK SUMMARY:\r\n\r\n";
                    report += summary;
                    report += "\r\n";
                }

                if (BDInfoSettings.AutosaveReport && reportFile != null)
                {
                    try { reportFile.Write(report); }
                    catch { }
                }
                textBoxReport.Text += report;
                report = "";
                GC.Collect();
            }

            if (BDInfoSettings.AutosaveReport && reportFile != null)
            {
                try { reportFile.Write(report); }
                catch { }
            }
            textBoxReport.Text += report;

            if (reportFile != null)
            {
                reportFile.Close();
            }

            textBoxReport.Select(0, 0);
            comboBoxPlaylist.SelectedIndex = 0;
            comboBoxChartType.SelectedIndex = 0;
        }
Ejemplo n.º 25
0
        public QuickReportData Generate(
            BDROM BDROM,
            List <TSPlaylistFile> playlists,
            ScanBDROMResult scanResult,
            String savePath = null
            )
        {
            var summary = new QuickReportData();

            if (!string.IsNullOrEmpty(BDROM.DiscTitle))
            {
                summary.DiscTitle = BDROM.DiscTitle;
            }

            summary.VolumeLabel = BDROM.VolumeLabel;
            summary.Size        = BDROM.Size;
            summary.Protection  = (BDROM.IsBDPlus ? "BD+" : BDROM.IsUHD ? "AACS2" : "AACS");
            summary.Playlists   = new List <PlaylistReport>();

            foreach (var playlist in playlists)
            {
                var playlistSummary = new PlaylistReport();
                playlistSummary.VideoStreams    = new List <StreamReport>();
                playlistSummary.AudioStreams    = new List <StreamReport>();
                playlistSummary.GraphicsStreams = new List <StreamReport>();
                playlistSummary.Name            = playlist.Name;
                playlistSummary.Size            = playlist.TotalSize;
                playlistSummary.Length          = new TimeSpan((long)(playlist.TotalLength * 10000000));
                playlistSummary.Bitrate         = playlist.TotalBitRate;

                foreach (var stream in playlist.SortedStreams)
                {
                    var streamSummary = new StreamReport();

                    streamSummary.CodecName = stream.CodecName;
                    if (stream.AngleIndex > 0)
                    {
                        streamSummary.AngleIndex    = stream.AngleIndex;
                        streamSummary.ActiveBitrate = stream.ActiveBitRate;
                    }

                    streamSummary.Bitrate      = stream.BitRate;
                    streamSummary.Description  = stream.Description;
                    streamSummary.LanguageName = stream.LanguageName;
                    streamSummary.IsHidden     = stream.IsHidden;

                    if (stream.IsVideoStream)
                    {
                        streamSummary.Type = "Video";
                        playlistSummary.VideoStreams.Add(streamSummary);
                    }
                    else if (stream.IsAudioStream)
                    {
                        streamSummary.Type = "Audio";
                        playlistSummary.AudioStreams.Add(streamSummary);
                    }
                    else if (stream.IsGraphicsStream)
                    {
                        streamSummary.Type = "Subtitle";
                        playlistSummary.GraphicsStreams.Add(streamSummary);
                    }

                    streamSummary.StreamInfo = StreamInfo.FromStream(stream);
                }

                summary.Playlists.Add(playlistSummary);
            }

            return(summary);
        }
Ejemplo n.º 26
0
 private void InitBDROMWork(
     object sender,
     DoWorkEventArgs e)
 {
     try
     {
         BDROM = new BDROM((string)e.Argument);
         BDROM.StreamClipFileScanError += new BDROM.OnStreamClipFileScanError(BDROM_StreamClipFileScanError);
         BDROM.StreamFileScanError += new BDROM.OnStreamFileScanError(BDROM_StreamFileScanError);
         BDROM.PlaylistFileScanError += new BDROM.OnPlaylistFileScanError(BDROM_PlaylistFileScanError);
         BDROM.Scan();
         e.Result = null;
     }
     catch (Exception ex)
     {
         e.Result = ex;
     }
 }
Ejemplo n.º 27
0
        private void OkButtonClick(object sender, RoutedEventArgs e)
        {
            if (SelectedTitle.SelectedIndex < 0) return;
            if (EncodingProfile.SelectedIndex < 0) return;

            JobInfo.JobName = FileTitle.Text;

            TreeNode selected = (TreeNode)SelectedTitle.SelectedItem;

            IEnumerable<TreeNode> sortedList = GetCheckedItems(selected);

            bool videoSet = false;

            foreach (TreeNode item in sortedList)
            {
                if (item.Data == null) continue;

                Type dataType = item.Data.GetType();

                if (dataType == typeof (string))
                    JobInfo.InputFile = (string) item.Data;
                else if (dataType == typeof (VideoInfo))
                {
                    if (!videoSet)
                    {
                        JobInfo.VideoStream = (VideoInfo) item.Data;
                        videoSet = true;
                    }
                }
                else if (dataType == typeof (StereoVideoInfo))
                    JobInfo.StereoVideoStream = (StereoVideoInfo) item.Data;
                else if (dataType == typeof (AudioInfo))
                    JobInfo.AudioStreams.Add((AudioInfo) item.Data);
                else if (dataType == typeof (SubtitleInfo))
                {
                    SubtitleInfo sub = (SubtitleInfo) item.Data;
                    if ((sub.Format == "PGS" || sub.Format == "VobSub") && (_bdInfo != null && !_bdInfo.Is3D))
                        // don't extract subtitles on 3d blurays, because eac3to can't handle them
                        JobInfo.SubtitleStreams.Add(sub);
                }
                else if (dataType == typeof (List<TimeSpan>))
                    JobInfo.Chapters.AddRange((List<TimeSpan>) item.Data);
                else if (dataType == typeof (Dictionary<string, object>))
                {
                    object itemData;
                    (item.Data as Dictionary<string, object>).TryGetValue("Name", out itemData);
                    if (itemData != null)
                        JobInfo.InputFile = (string) itemData;
                    (item.Data as Dictionary<string, object>).TryGetValue("PlaylistIndex", out itemData);
                    if (itemData != null)
                        JobInfo.StreamId = (int) itemData;
                    (item.Data as Dictionary<string, object>).TryGetValue("TrackID", out itemData);
                    if (itemData != null)
                        JobInfo.TrackId = (int) itemData;
                }
            }
            JobInfo.StreamId = -1;

            if (_profiles != null)
            {
                QuickSelectProfile encProfile = (QuickSelectProfile)EncodingProfile.SelectedItem;
                EncoderProfile videoEncoder = GetProfile(encProfile.VideoProfile, encProfile.VideoProfileType);
                EncoderProfile audioEncoder = GetProfile(encProfile.AudioProfile, encProfile.AudioProfileType);
                JobInfo.AudioProfile = audioEncoder;
                JobInfo.VideoProfile = videoEncoder;
                JobInfo.EncodingProfile = encProfile;
            }

            AppSettings.LastSelectedProfile = (string)EncodingProfile.SelectedValue;
            AppSettings.SaveSettings();

            if (AppSettings.CreateXbmcInfoFile)
            {
                JobInfo.MovieInfo = _resultMovieData;
                JobInfo.PosterImage = _resultPosterImage;
                JobInfo.BackDropImage = _resultBackdropImage;
            }

            _bdInfo = null;
            DialogResult = true;
        }