Пример #1
0
        /// <summary>
        /// gets chapters from IFO file and save them as Ogg Text File
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns>chapter file name</returns>
        public static String getChaptersFromIFO(string fileName, bool qpfile, string outputDirectory, int iPGCNumber)
        {
            if (Path.GetExtension(fileName.ToLowerInvariant()) == ".vob" ||
                Path.GetExtension(fileName.ToLowerInvariant()) == ".ifo")
            {
                string ifoFile;
                string fileNameNoPath = Path.GetFileName(fileName);
                if (String.IsNullOrEmpty(outputDirectory))
                {
                    outputDirectory = Path.GetDirectoryName(fileName);
                }

                // we check the main IFO
                if (fileNameNoPath.Substring(0, 4).ToUpper(System.Globalization.CultureInfo.InvariantCulture) == "VTS_")
                {
                    ifoFile = fileName.Substring(0, fileName.LastIndexOf("_")) + "_0.IFO";
                }
                else
                {
                    ifoFile = Path.ChangeExtension(fileName, ".IFO");
                }

                if (File.Exists(ifoFile))
                {
                    ChapterInfo  pgc;
                    IfoExtractor ex = new IfoExtractor();
                    pgc = ex.GetChapterInfo(ifoFile, iPGCNumber);
                    if (pgc == null)
                    {
                        return(null);
                    }
                    if (Drives.ableToWriteOnThisDrive(Path.GetPathRoot(outputDirectory)))
                    {
                        if (qpfile)
                        {
                            pgc.SaveQpfile(outputDirectory + "\\" + fileNameNoPath.Substring(0, 6) + " - Chapter Information.qpf");
                        }

                        // save always this format - some users want it for the mux
                        pgc.SaveText(outputDirectory + "\\" + fileNameNoPath.Substring(0, 6) + " - Chapter Information.txt");
                        return(outputDirectory + "\\" + fileNameNoPath.Substring(0, 6) + " - Chapter Information.txt");
                    }
                    else
                    {
                        MessageBox.Show("MeGUI cannot write on the disc " + Path.GetPathRoot(ifoFile) + " \n" +
                                        "Please, select another output path to save the chapters file...", "Configuration Incomplete", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// checks if the input file has chapters
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns>true if the file has chapters</returns>
        public static bool HasChapters(MediaInfoFile iFile)
        {
            if (iFile.HasChapters)
            {
                return(true);
            }

            if (Path.GetExtension(iFile.FileName.ToLowerInvariant()) != ".vob" &&
                Path.GetExtension(iFile.FileName.ToLowerInvariant()) != ".ifo")
            {
                return(false);
            }

            // detect ifo file
            string videoIFO = String.Empty;

            if (Path.GetExtension(iFile.FileName.ToLowerInvariant()) == ".vob")
            {
                // find the main IFO
                if (Path.GetFileName(iFile.FileName).ToUpperInvariant().Substring(0, 4) == "VTS_")
                {
                    videoIFO = iFile.FileName.Substring(0, iFile.FileName.LastIndexOf("_")) + "_0.IFO";
                }
                else
                {
                    videoIFO = Path.ChangeExtension(iFile.FileName, ".IFO");
                }
            }

            if (!File.Exists(videoIFO))
            {
                return(false);
            }

            int iPGCNumber = 1;

            if (iFile.VideoInfo.PGCNumber > 0)
            {
                iPGCNumber = iFile.VideoInfo.PGCNumber;
            }

            IfoExtractor ex  = new IfoExtractor();
            ChapterInfo  pgc = ex.GetChapterInfo(videoIFO, iPGCNumber);

            if (pgc != null && pgc.HasChapters)
            {
                return(true);
            }
            return(false);
        }
Пример #3
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);
        }
Пример #4
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);
        }