예제 #1
0
        private void btInput_Click(object sender, EventArgs e)
        {
            if (rbFromFile.Checked)
            {
                openFileDialog.Filter = "IFO Files (*.ifo)|*.ifo|MPLS Files (*.mpls)|*.mpls|Text Files (*.txt)|*.txt|All Files supported (*.ifo,*.mpls,*.txt)|*.ifo;*.mpls;*.txt";
                openFileDialog.FilterIndex = 4;

               if (this.openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    input.Text = openFileDialog.FileName;

                    if (input.Text.ToLower().EndsWith("ifo"))
                    {
                        ChapterExtractor ex = new IfoExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else if (input.Text.ToLower().EndsWith("mpls"))
                    {
                        ChapterExtractor ex = new MplsExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                    else
                    {
                        ChapterExtractor ex = new TextExtractor();
                        pgc = ex.GetStreams(input.Text)[0];
                        FreshChapterView();
                        updateTimeLine();
                    }
                }
            }
            else
            {
                using (FolderBrowserDialog d = new FolderBrowserDialog())
                {
                    d.ShowNewFolderButton = false;
                    d.Description = "Select DVD, BluRay disc, or folder.";
                    if (d.ShowDialog() == DialogResult.OK)
                    {
                        input.Text = d.SelectedPath;
                        try
                        {
                            ChapterExtractor ex =
                              Directory.Exists(Path.Combine(input.Text, "VIDEO_TS")) ?
                              new DvdExtractor() as ChapterExtractor :
                              Directory.Exists(Path.Combine(Path.Combine(input.Text, "BDMV"), "PLAYLIST")) ?
                              new BlurayExtractor() as ChapterExtractor :
                              null;

                            if (ex == null)
                                throw new Exception("The location was not detected as DVD, or Blu-Ray.");

                            using (frmStreamSelect frm = new frmStreamSelect(ex))
                            {
                                if (ex is DvdExtractor)
                                    frm.Text = "Select your PGC";
                                else
                                    frm.Text = "Select your Playlist";
                                ex.GetStreams(input.Text);
                                if (frm.ShowDialog(this) == DialogResult.OK)
                                {
                                    pgc = frm.ProgramChain;
                                    if (pgc.FramesPerSecond == 0) pgc.FramesPerSecond = 25.0;
                                    if (pgc.LangCode == null) pgc.LangCode = "und";
                                }
                            }
                            FreshChapterView();
                            updateTimeLine();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }

            if (chapterListView.Items.Count != 0)
                chapterListView.Items[0].Selected = true;
        }
예제 #2
0
        public override List <ChapterInfo> GetStreams(string location)
        {
            string videoIFO;
            string path;

            if (File.Exists(location) && Path.GetExtension(location).ToLower(System.Globalization.CultureInfo.InvariantCulture).Equals(".ifo"))
            {
                path     = Path.GetDirectoryName(location);
                videoIFO = location;
            }
            else if (Directory.Exists(location) && Directory.GetFiles(location, "*.IFO").Length > 0)
            {
                path     = location;
                videoIFO = Path.Combine(path, "VIDEO_TS.IFO");
            }
            else if (Directory.Exists(Path.Combine(location, "VIDEO_TS")) && Directory.GetFiles(Path.Combine(location, "VIDEO_TS"), "*.IFO").Length > 0)
            {
                path     = Path.Combine(location, "VIDEO_TS");
                videoIFO = Path.Combine(path, "VIDEO_TS.IFO");
            }
            else
            {
                throw new FileNotFoundException("No DVD IFO data found in " + location);
            }

            List <ChapterInfo> streams = new List <ChapterInfo>();

            IfoExtractor ex = new IfoExtractor();

            ex.StreamDetected += (sender, args) => OnStreamDetected(args.ProgramChain);
            ex.ChaptersLoaded += (sender, args) => OnChaptersLoaded(args.ProgramChain);

            if (File.Exists(videoIFO) && Path.GetFileName(videoIFO).ToUpper(System.Globalization.CultureInfo.InvariantCulture).Equals("VIDEO_TS.IFO"))
            {
                byte[] bytRead = new byte[4];
                long   VMG_PTT_STPT_Position = IFOparser.ToFilePosition(IFOparser.GetFileBlock(videoIFO, 0xC4, 4));
                int    titlePlayMaps         = IFOparser.ToInt16(IFOparser.GetFileBlock(videoIFO, VMG_PTT_STPT_Position, 2));

                // get PGC count from all ifo files
                int pgcCount = 0;
                foreach (string file in Directory.GetFiles(path, "VTS_*_0.IFO"))
                {
                    pgcCount += (int)IFOparser.getPGCnb(file);
                }

                if (pgcCount > titlePlayMaps)
                {
                    // process all the ifo files as there are more PGCs than in the VIDEO_TS.IFO
                    foreach (string file in Directory.GetFiles(path, "VTS_*_0.IFO"))
                    {
                        streams.AddRange(ex.GetStreams(file));
                    }
                }
                else
                {
                    for (int currentTitle = 1; currentTitle <= titlePlayMaps; ++currentTitle)
                    {
                        long   titleInfoStart      = 8 + ((currentTitle - 1) * 12);
                        int    titleSetNumber      = IFOparser.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 6L, 1)[0];
                        int    titleSetTitleNumber = IFOparser.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 7L, 1)[0];
                        string vtsIFO = Path.Combine(path, string.Format("VTS_{0:D2}_0.IFO", titleSetNumber));
                        if (!File.Exists(vtsIFO))
                        {
                            Trace.WriteLine(string.Format("VTS IFO file missing: {0}", Path.GetFileName(vtsIFO)));
                            continue;
                        }
                        streams.Add(ex.GetChapterInfo(vtsIFO, titleSetTitleNumber));
                    }
                }
            }
            else if (File.Exists(videoIFO))
            {
                // read only the selected ifo file
                streams.AddRange(ex.GetStreams(videoIFO));
            }
            else
            {
                // read all the ifo files
                foreach (string file in Directory.GetFiles(path, "VTS_*_0.IFO"))
                {
                    streams.AddRange(ex.GetStreams(file));
                }
            }

            OnExtractionComplete();
            return(streams);
        }
예제 #3
0
        public override List <ChapterInfo> GetStreams(string location)
        {
            List <ChapterInfo> streams = new List <ChapterInfo>();

            string videoIFO = FileUtil.GetDVDPath(location);

            if (string.IsNullOrEmpty(videoIFO))
            {
                return(streams);
            }

            IfoExtractor ex = new IfoExtractor();

            ex.StreamDetected += (sender, args) => OnStreamDetected(args.ProgramChain);
            ex.ChaptersLoaded += (sender, args) => OnChaptersLoaded(args.ProgramChain);

            if (File.Exists(videoIFO) && Path.GetFileName(videoIFO).ToUpperInvariant().Equals("VIDEO_TS.IFO"))
            {
                byte[] bytRead = new byte[4];
                long   VMG_PTT_STPT_Position = IFOparser.ToFilePosition(IFOparser.GetFileBlock(videoIFO, 0xC4, 4));
                int    titlePlayMaps         = IFOparser.ToInt16(IFOparser.GetFileBlock(videoIFO, VMG_PTT_STPT_Position, 2));

                // get PGC count from all ifo files
                int pgcCount = 0;
                foreach (string file in Directory.GetFiles(Path.GetDirectoryName(videoIFO), "VTS_*_0.IFO"))
                {
                    pgcCount += IFOparser.GetPGCCount(file);
                }

                if (pgcCount > titlePlayMaps)
                {
                    // process all the ifo files as there are more PGCs than in the VIDEO_TS.IFO
                    foreach (string file in Directory.GetFiles(Path.GetDirectoryName(videoIFO), "VTS_*_0.IFO"))
                    {
                        streams.AddRange(ex.GetStreams(file));
                    }
                }
                else
                {
                    for (int currentTitle = 1; currentTitle <= titlePlayMaps; ++currentTitle)
                    {
                        long   titleInfoStart      = 8 + ((currentTitle - 1) * 12);
                        int    titleSetNumber      = IFOparser.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 6L, 1)[0];
                        int    titleSetTitleNumber = IFOparser.GetFileBlock(videoIFO, (VMG_PTT_STPT_Position + titleInfoStart) + 7L, 1)[0];
                        string vtsIFO = Path.Combine(Path.GetDirectoryName(videoIFO), string.Format("VTS_{0:D2}_0.IFO", titleSetNumber));
                        if (!File.Exists(vtsIFO))
                        {
                            Trace.WriteLine(string.Format("VTS IFO file missing: {0}", Path.GetFileName(vtsIFO)));
                            continue;
                        }
                        int iAngleCount = IFOparser.GetAngleCount(vtsIFO, titleSetTitleNumber);
                        for (int i = 0; i <= iAngleCount; i++)
                        {
                            if (i == 0 && iAngleCount > 0)
                            {
                                continue;
                            }
                            ChapterInfo oChapterInfo = ex.GetChapterInfo(vtsIFO, titleSetTitleNumber);
                            oChapterInfo.AngleNumber = i;
                            streams.Add(oChapterInfo);
                        }
                    }
                }
            }
            else if (File.Exists(videoIFO))
            {
                // read only the selected ifo file
                streams.AddRange(ex.GetStreams(videoIFO));
            }
            else
            {
                // read all the ifo files
                foreach (string file in Directory.GetFiles(Path.GetDirectoryName(videoIFO), "VTS_*_0.IFO"))
                {
                    streams.AddRange(ex.GetStreams(file));
                }
            }

            OnExtractionComplete();
            return(streams);
        }