Beispiel #1
0
        public override List <ChapterInfo> GetStreams(string location, int numtitle)
        {
            ChapterInfo pgc = new ChapterInfo();

            pgc.Chapters   = new List <ChapterEntry>();
            pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
            pgc.SourceName = location;
            pgc.Title      = Path.GetFileNameWithoutExtension(location);
            pgc.SourceType = "Blu-Ray";
            pgc.Extractor  = Application.ProductName + " " + Application.ProductVersion;

            FileInfo fileInfo = new FileInfo(location);

            OnStreamDetected(pgc);
            TSPlaylistFile mpls = new TSPlaylistFile(fileInfo);

            //Dictionary<string, TSStreamClipFile> clips = new Dictionary<string,TSStreamClipFile>();
            mpls.Scan();
            foreach (double d in mpls.Chapters)
            {
                pgc.Chapters.Add(new ChapterEntry()
                {
                    Name = string.Empty,
                    Time = new TimeSpan((long)(d * (double)TimeSpan.TicksPerSecond))
                });
            }

            pgc.Duration = new TimeSpan((long)(mpls.TotalLength * (double)TimeSpan.TicksPerSecond));

            foreach (TSStreamClip clip in mpls.StreamClips)
            {
                clip.StreamClipFile.Scan();
                foreach (TSStream stream in clip.StreamClipFile.Streams.Values)
                {
                    if (stream.IsVideoStream)
                    {
                        pgc.FramesPerSecond = (double)((TSVideoStream)stream).FrameRateEnumerator /
                                              (double)((TSVideoStream)stream).FrameRateDenominator;
                        break;
                    }
                }
                if (pgc.FramesPerSecond != 0)
                {
                    break;
                }
            }

            OnChaptersLoaded(pgc);
            OnExtractionComplete();
            return(new List <ChapterInfo>()
            {
                pgc
            });
        }
Beispiel #2
0
        public override List <ChapterInfo> GetStreams(string location)
        {
            ChapterInfo pgc = new ChapterInfo();

            pgc.Chapters   = new List <Chapter>();
            pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
            pgc.SourceName = location;
            pgc.Title      = Path.GetFileNameWithoutExtension(location);
            pgc.SourceType = "Blu-Ray";

            DirectoryInfo DirectoryBDMV = GetDirectoryBDMV(location);

            if (DirectoryBDMV == null)
            {
                throw new Exception("Unable to locate BD structure.");
            }

            DirectoryInfo DirectoryRoot =
                DirectoryBDMV.Parent;
            DirectoryInfo DirectoryBDJO =
                GetDirectory("BDJO", DirectoryBDMV, 0);
            DirectoryInfo DirectoryCLIPINF =
                GetDirectory("CLIPINF", DirectoryBDMV, 0);
            DirectoryInfo DirectoryPLAYLIST =
                GetDirectory("PLAYLIST", DirectoryBDMV, 0);
            DirectoryInfo DirectorySNP =
                GetDirectory("SNP", DirectoryRoot, 0);
            DirectoryInfo DirectorySTREAM =
                GetDirectory("STREAM", DirectoryBDMV, 0);
            DirectoryInfo DirectorySSIF =
                GetDirectory("SSIF", DirectorySTREAM, 0);

            Dictionary <string, TSStreamClipFile> StreamClipFiles = new Dictionary <string, TSStreamClipFile>();
            Dictionary <string, TSStreamFile>     StreamFiles     = new Dictionary <string, TSStreamFile>();

            if (DirectorySTREAM != null)
            {
                FileInfo[] files = DirectorySTREAM.GetFiles("*.m2ts");
                if (files.Length == 0)
                {
                    files = DirectoryPLAYLIST.GetFiles("*.M2TS");
                }
                foreach (FileInfo file in files)
                {
                    StreamFiles.Add(file.Name.ToUpper(), new TSStreamFile(file));
                }
            }

            if (DirectoryCLIPINF != null)
            {
                FileInfo[] files = DirectoryCLIPINF.GetFiles("*.clpi");
                if (files.Length == 0)
                {
                    files = DirectoryPLAYLIST.GetFiles("*.CLPI");
                }
                foreach (FileInfo file in files)
                {
                    StreamClipFiles.Add(file.Name.ToUpper(), new TSStreamClipFile(file));
                }
            }

            FileInfo       fileInfo = new FileInfo(location);
            TSPlaylistFile mpls     = new TSPlaylistFile(fileInfo);

            mpls.Scan(StreamFiles, StreamClipFiles);

            int count = 1;

            foreach (double d in mpls.Chapters)
            {
                pgc.Chapters.Add(new Chapter()
                {
                    Name = "Chapter " + count.ToString("D2"),
                    Time = new TimeSpan((long)(d * (double)TimeSpan.TicksPerSecond))
                });
                count++;
            }

            pgc.Duration = new TimeSpan((long)(mpls.TotalLength * (double)TimeSpan.TicksPerSecond));

            foreach (TSStreamClip clip in mpls.StreamClips)
            {
                clip.StreamClipFile.Scan();
                foreach (TSStream stream in clip.StreamClipFile.Streams.Values)
                {
                    if (stream.IsVideoStream)
                    {
                        pgc.FramesPerSecond = VideoUtil.ConvertFPSFractionToDouble(((TSVideoStream)stream).FrameRateEnumerator, ((TSVideoStream)stream).FrameRateDenominator);
                        break;
                    }
                }
                if (pgc.FramesPerSecond != 0)
                {
                    break;
                }
            }

            if (pgc.Duration.TotalSeconds > MainForm.Instance.Settings.ChapterCreatorMinimumLength)
            {
                OnStreamDetected(pgc);
                OnChaptersLoaded(pgc);
            }
            else
            {
                pgc = null;
            }
            OnExtractionComplete();
            return(new List <ChapterInfo>()
            {
                pgc
            });
        }