private void openVideo(string fileName) { input.Filename = fileName; subtitleTracks.Items.Clear(); subtitleTracks.Items.AddRange(IFOparser.GetSubtitlesStreamsInfos(input.Filename)); demuxSelectedTracks.Checked = !keepAllTracks.Checked; }
private void openVideo(string fileName) { if (input.Filename != fileName) { input.Filename = fileName; } string projectPath; string fileNameNoPath = Path.GetFileName(fileName); if (string.IsNullOrEmpty(projectPath = mainForm.Settings.DefaultOutputDir)) { projectPath = Path.GetDirectoryName(fileName); } projectName.Text = Path.Combine(projectPath, Path.ChangeExtension(fileNameNoPath, ".d2v")); AudioTracks.Items.Clear(); demuxNoAudiotracks.Checked = true; // here to trigger rbtracks_CheckedChanged on new File selection if (Path.GetExtension(fileName.ToLower()) == ".vob") { string ifoFile; if (fileNameNoPath.Substring(0, 4) == "VTS_") { ifoFile = fileName.Substring(0, fileName.LastIndexOf("_")) + "_0.IFO"; } else { ifoFile = Path.ChangeExtension(fileName, ".IFO"); } if (File.Exists(ifoFile)) { AudioTracks.Items.AddRange(IFOparser.GetAudioInfos(ifoFile, false)); } } if (AudioTracks.Items.Count < 1) { int unused; List <AudioTrackInfo> audioTracks; vUtil.getSourceMediaInfo(fileName, out audioTracks, out unused); foreach (AudioTrackInfo atrack in audioTracks) { AudioTracks.Items.Add(atrack); } } if (AudioTracks.Items.Count > 0) { demuxTracks.Checked = true; AudioTracks.Enabled = true; demuxTracks.Enabled = true; } else { MessageBox.Show("MeGUI cannot find audio track information. Audio Tracks selection will be disabled."); } }
private void openVideo(string fileName) { input.Filename = fileName; subtitleTracks.Items.Clear(); uint nbPGC = IFOparser.getPGCnb(fileName); pgc.Maximum = nbPGC; subtitleTracks.Items.AddRange(IFOparser.GetSubtitlesStreamsInfos(input.Filename, Convert.ToInt32(pgc.Value), chkShowAllStreams.Checked)); demuxSelectedTracks.Checked = !keepAllTracks.Checked; }
public override List <ChapterInfo> GetStreams(string ifoFile) { List <ChapterInfo> oList = new List <ChapterInfo>(); ChapterInfo oChapterInfo; int pgcCount = (int)IFOparser.getPGCnb(ifoFile); for (int i = 1; i <= pgcCount; i++) { oChapterInfo = GetChapterInfo(ifoFile, i); oList.Add(oChapterInfo); } return(oList); }
private void SetSubtitles() { subtitleTracks.Items.Clear(); subtitleTracks.Items.AddRange(IFOparser.GetSubtitlesStreamsInfos(input.Filename, iPGC, chkShowAllStreams.Checked)); PreselectItems(); // get proper pre- and postfix based on the input file string filePath = FileUtil.GetOutputFolder(input.Filename); string filePrefix = FileUtil.GetOutputFilePrefix(input.Filename); string fileName = Path.GetFileNameWithoutExtension(input.Filename); if (FileUtil.RegExMatch(fileName, @"_\d{1,2}\z", false)) { fileName = fileName.Substring(0, fileName.LastIndexOf('_') + 1); } else { fileName = fileName + "_"; } output.Filename = Path.Combine(filePath, filePrefix + fileName + iPGC + (iAngle > 0 ? "_" + iAngle : "") + ".idx"); }
public override List <ChapterInfo> GetStreams(string ifoFile) { List <ChapterInfo> oList = new List <ChapterInfo>(); int pgcCount = IFOparser.GetPGCCount(ifoFile); for (int i = 1; i <= pgcCount; i++) { int iAngleCount = IFOparser.GetAngleCount(ifoFile, i); for (int a = 0; a <= iAngleCount; a++) { if (a == 0 && iAngleCount > 0) { continue; } ChapterInfo oChapterInfo = GetChapterInfo(ifoFile, i); oChapterInfo.AngleNumber = a; oList.Add(oChapterInfo); } } return(oList); }
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); }
List <Chapter> GetChapters(string ifoFile, int programChain, out TimeSpan duration, out double fps) { List <Chapter> chapters = new List <Chapter>(); duration = TimeSpan.Zero; fps = 0; long pcgITPosition = IFOparser.GetPCGIP_Position(ifoFile); int programChainPrograms = -1; TimeSpan programTime = TimeSpan.Zero; if (programChain >= 0) { double FPS; uint chainOffset = IFOparser.GetChainOffset(ifoFile, pcgITPosition, programChain); programTime = IFOparser.ReadTimeSpan(ifoFile, pcgITPosition, chainOffset, out FPS) ?? TimeSpan.Zero; programChainPrograms = IFOparser.GetNumberOfPrograms(ifoFile, pcgITPosition, chainOffset); } else { int programChains = IFOparser.GetProgramChains(ifoFile, pcgITPosition); for (int curChain = 1; curChain <= programChains; curChain++) { double FPS; uint chainOffset = IFOparser.GetChainOffset(ifoFile, pcgITPosition, curChain); TimeSpan?time = IFOparser.ReadTimeSpan(ifoFile, pcgITPosition, chainOffset, out FPS); if (time == null) { break; } if (time.Value > programTime) { programChain = curChain; programChainPrograms = IFOparser.GetNumberOfPrograms(ifoFile, pcgITPosition, chainOffset); programTime = time.Value; } } } if (programChain < 0) { return(null); } chapters.Add(new Chapter() { Name = "Chapter 01" }); uint longestChainOffset = IFOparser.GetChainOffset(ifoFile, pcgITPosition, programChain); int programMapOffset = IFOparser.ToInt16(IFOparser.GetFileBlock(ifoFile, (pcgITPosition + longestChainOffset) + 230, 2)); int cellTableOffset = IFOparser.ToInt16(IFOparser.GetFileBlock(ifoFile, (pcgITPosition + longestChainOffset) + 0xE8, 2)); for (int currentProgram = 0; currentProgram < programChainPrograms; ++currentProgram) { int entryCell = IFOparser.GetFileBlock(ifoFile, ((pcgITPosition + longestChainOffset) + programMapOffset) + currentProgram, 1)[0]; int exitCell = entryCell; if (currentProgram < (programChainPrograms - 1)) { exitCell = IFOparser.GetFileBlock(ifoFile, ((pcgITPosition + longestChainOffset) + programMapOffset) + (currentProgram + 1), 1)[0] - 1; } TimeSpan totalTime = TimeSpan.Zero; for (int currentCell = entryCell; currentCell <= exitCell; currentCell++) { int cellStart = cellTableOffset + ((currentCell - 1) * 0x18); byte[] bytes = IFOparser.GetFileBlock(ifoFile, (pcgITPosition + longestChainOffset) + cellStart, 4); int cellType = bytes[0] >> 6; if (cellType == 0x00 || cellType == 0x01) { bytes = IFOparser.GetFileBlock(ifoFile, ((pcgITPosition + longestChainOffset) + cellStart) + 4, 4); TimeSpan time = IFOparser.ReadTimeSpan(bytes, out fps) ?? TimeSpan.Zero; totalTime += time; } } //add a constant amount of time for each chapter? //totalTime += TimeSpan.FromMilliseconds(fps != 0 ? (double)1000 / fps / 8D : 0); duration += totalTime; if (currentProgram + 1 < programChainPrograms) { chapters.Add(new Chapter() { Name = string.Format("Chapter {0:D2}", currentProgram + 2), Time = duration }); } } return(chapters); }
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); }