/// <summary> /// Adds chapter fields to File Objects. /// </summary> /// <param name="file">The FileObject processed by InfoDumper.InfoDump.</param> /// <returns>The FileObjct with chapter fields.</returns> public FileObject chapterDump(FileObject file) { int chapterNum = 0; string timeStart = ""; string timeEnd = ""; string chsuid = ""; MatchCollection matches = Regex.Matches(file.mkvInfo, @"\| \+ ChapterAtom\r*\n((\| .*\r*\n)*)"); Match fSuid = Regex.Match(file.mkvInfo, @"\| \+ Segment UID: (0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+)"); file.suid = fSuid.Groups[1].Value; foreach (Match match in matches) { Match mTimeStart = Regex.Match(match.Value, @"\| \+ ChapterTimeStart: (\d\d:\d\d:\d\d\.\d{8})"); Match mTimeEnd = Regex.Match(match.Value, @"\| \+ ChapterTimeEnd: (\d\d:\d\d:\d\d\.\d{8})"); ; Match mSuid = Regex.Match(match.Value, @"\| \+ ChapterSegmentUID:.* (0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+)"); ; timeStart = mTimeStart.Groups[1].Value; timeEnd = mTimeEnd.Groups[1].Value; chsuid = mSuid.Groups[1].Value; if (Config.Configure.includeChapterInfoOnFiles) file.addChapter(chapterNum, timeStart, timeEnd, chsuid, match.Value); else file.addChapter(chapterNum, timeStart, timeEnd, chsuid); chapterNum++; } return file; }
/// <summary> /// Deprecated. Dumps entire media info from FFprobe output. /// </summary> /// <param name="file">The FileObject to process.</param> /// <returns>The FileObject processed.</returns> public static FileObject ffProbeDump(FileObject file) { ProcessStartInfo p = new ProcessStartInfo(Program.ffprobeExe); string output = ""; p.Arguments = "-show_streams -i \"" + file.fullpath + "\""; p.UseShellExecute = false; p.CreateNoWindow = true; p.WindowStyle = ProcessWindowStyle.Hidden; p.RedirectStandardOutput = true; p.RedirectStandardError = true; using (Process process = Process.Start(p)) { /* using (StreamReader reader = process.StandardError) { output = reader.ReadToEnd(); } */ using (StreamReader reader = process.StandardOutput) { output += reader.ReadToEnd(); } file.addFFInfo(output); process.WaitForExit(); } return file; }
public SuidLister(FileObject file) { var suidobj = new Suid(); suidobj.fileName = file.filename; suidobj.fullPath = file.fullpath; suidobj.suid = file.suid; if (!String.IsNullOrWhiteSpace(suidobj.suid)) { suidList.Add(suidobj); } }
public void addSuid(FileObject file) { var suidobj = new Suid(); suidobj.fileName = file.filename; suidobj.fullPath = file.fullpath; suidobj.suid = file.suid; //Console.WriteLine("New SUID Object suid: " + file.suid); if (!String.IsNullOrWhiteSpace(suidobj.suid)) { suidList.Add(suidobj); } }
/// <summary> /// Adds chapter fields to File Objects. /// </summary> /// <param name="file">The FileObject processed by InfoDumper.InfoDump.</param> /// <returns>The FileObjct with chapter fields.</returns> public FileObject chapterDump(FileObject file) { int chapterNum = 0; string timeStart = ""; string timeEnd = ""; string chsuid = ""; MatchCollection matches = Regex.Matches(file.mkvInfo, @"\| \+ ChapterAtom\r*\n((\| .*\r*\n)*)"); Match fSuid = Regex.Match(file.mkvInfo, @"\| \+ Segment UID: (0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+)"); file.suid = fSuid.Groups[1].Value; foreach (Match match in matches) { Match mTimeStart = Regex.Match(match.Value, @"\| \+ ChapterTimeStart: (\d\d:\d\d:\d\d\.\d{8})"); Match mTimeEnd = Regex.Match(match.Value, @"\| \+ ChapterTimeEnd: (\d\d:\d\d:\d\d\.\d{8})");; Match mSuid = Regex.Match(match.Value, @"\| \+ ChapterSegmentUID:.* (0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+ 0x\w+)");; timeStart = mTimeStart.Groups[1].Value; timeEnd = mTimeEnd.Groups[1].Value; chsuid = mSuid.Groups[1].Value; if (Config.Configure.includeChapterInfoOnFiles) { file.addChapter(chapterNum, timeStart, timeEnd, chsuid, match.Value); } else { file.addChapter(chapterNum, timeStart, timeEnd, chsuid); } chapterNum++; } return(file); }
/// <summary> /// Dumps entire media info from FFmpeg output. /// </summary> /// <param name="file">The FileObject to process.</param> /// <returns>The FileObject processed.</returns> public static FileObject ffInfoDump(FileObject file) { ProcessStartInfo p = new ProcessStartInfo(Program.ffmpegExe); p.Arguments = "-i \"" + file.fullpath + "\""; p.UseShellExecute = false; p.CreateNoWindow = true; p.WindowStyle = ProcessWindowStyle.Hidden; p.RedirectStandardOutput = true; p.RedirectStandardError = true; using (Process process = Process.Start(p)) { using (StreamReader reader = process.StandardError) { string output = reader.ReadToEnd(); file.addFFInfo(output); } process.WaitForExit(); } return(file); }
/// <summary> /// Checks if file extension is valid for merging/converting. /// </summary> /// <param name="file">The FileObject to process.</param> /// <returns>True if file extension is valid; else, false.</returns> public static bool ValidateExtension(FileObject file) { bool valid = false; //Temporary list of extensions; maybe replaced by a more proper global list in the future. string[] extensions = { ".mkv", ".mp4", ".mpeg", ".avi", ".wmv", ".aac", ".ogg", ".mp3", ".m4a", ".jpg", ".jpeg", ".png", ".bmp", ".tga" }; foreach (string extension in MediaData.extensions) { if (file.extension == extension) { valid = true; } else { valid = false; } } return(valid); }
/// <summary> /// Processes files to create File Objects for the main tasks of this program. /// Every tasks are denoted on each comment lines inside the method. /// </summary> /// <param name="list">The list that contains the fullpaths of the actual files.</param> /// <param name="listname">Name for the FileObjectCollection to be created.</param> /// <param name="processor">The Analyze object for progression report.</param> /// <param name="path">The path used as a working directory merge commands.</param> /// <param name="totalArguments">Optional. For progress report. The total number of lists to process.</param> public void processList(List <string> list, string listname, Analyze processor, string path = "C:\\", int totalArguments = 0) { FileObjectCollection fileList = new FileObjectCollection(); TrackLister tracklist = new TrackLister(); MakeFile makeFile = new MakeFile(); ChapterGenerator chapterGet = new ChapterGenerator(); ProgressState progressState = new ProgressState(); fileList.folderPath = path; fileList.name = listname; progressState.listName = fileList.name; progress = 1; processPercent = 0; foreach (string s in list) { progressState.progressDetail = "Creating file entry..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); FileObject file = new FileObject(s); processPercent = progress.ToPercentage(list.Count); progressState.progressPercent = processPercent; progressState.fileName = file.filename; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); //Routine after splitting //Checks if current backgroundWorker operation is cancelled //Stops this program if true if (Analyze.backgroundWorker.CancellationPending) { return; } if (file.extension == ".mkv") { try { file = InfoDumper.infoDump(file); } catch (Exception ex) { Program.Message("Error:\r\n\r\n" + ex.Message, "Error"); } progressState.progressDetail = "Dumping MKV info..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); file = chapterGet.chapterDump(file); if (!Config.Configure.includeMkvInfoOnFiles) { file.mkvInfo = null; } if (!Config.Configure.includeMediaInfoOnFiles) { file.ffInfo = null; } progressState.progressDetail = "Getting chapters' info..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); fileList.hasMKV = true; } if (Program.hasFFmpeg) { progressState.progressDetail = "Dumping media info..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); try { file = InfoDumper.ffInfoDump(file); } catch (Exception ex) { Program.Message("Error:\r\n\r\n" + ex.Message, "Error"); } if (!String.IsNullOrEmpty(file.ffInfo)) { file = chapterGet.mediaDump(file); } } fileList.addFile(file); progress++; } if (fileList.hasMKV) { SuidLister suidList = CreateSuidLister(fileList); progressState.progressDetail = "Creating SUID list..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); fileList = tracklist.arrangeTrack(fileList, suidList, processor); progressState.progressDetail = "Arranging new tracklist for every file..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); //For Diagnostic purposes only if (Config.Configure.diagnose >= 30) { foreach (Suid suid in suidList.suidList) { { Console.WriteLine("SUID filename: " + suid.fileName); Console.WriteLine("SUID: " + suid.suid); Console.WriteLine("\n"); } } Console.WriteLine("fileList.fileList.Count: " + fileList.fileList.Count + "\n"); foreach (FileObject file in fileList.fileList) { //Console.WriteLine("Merge Argument count: {0}\n", file.mergeArgument.Count); foreach (MergeArgument merge in file.mergeArgument) { Console.WriteLine("Merge Argument:\nFile name: {0}\nTime Code: {1}\nFile Argument: {2}\nChapter Number: {3}\n", file.filename, merge.timeCode, merge.fileName, merge.chapterNum); } foreach (TimeCode time in file.timeCode) { Console.WriteLine("Time Code Argument: {0}\n", time.timeCode); } foreach (DelArgument del in file.delArgument) { Console.WriteLine("Del Argument: {0}\n", del.fileName); } } } if (Config.Configure.doMakeScript) { makeFile.makeFile(fileList, processor); progressState.progressDetail = "Creating Merge Script..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); } } if (Config.Configure.doMakeXml) { makeFile.makeXML(fileList, processor); progressState.progressDetail = "Dumping XML file..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); } processor.fileLists.Add(fileList); }
public void addFile(FileObject file) { fileList.Add(file); }
public SuidLister(FileObject file) { var suidobj = new Suid(); suidobj.fileName = file.filename; suidobj.fullPath = file.fullpath; suidobj.suid = file.suid; if (!String.IsNullOrWhiteSpace(suidobj.suid)) suidList.Add(suidobj); }
public void addFile(FileObject file) { fileList.Add(file); }
public void addSuid(FileObject file) { var suidobj = new Suid(); suidobj.fileName = file.filename; suidobj.fullPath = file.fullpath; suidobj.suid = file.suid; //Console.WriteLine("New SUID Object suid: " + file.suid); if (!String.IsNullOrWhiteSpace(suidobj.suid)) suidList.Add(suidobj); }
/// <summary> /// Processes files to create File Objects for the main tasks of this program. /// Every tasks are denoted on each comment lines inside the method. /// </summary> /// <param name="list">The list that contains the fullpaths of the actual files.</param> /// <param name="listname">Name for the FileObjectCollection to be created.</param> public void AnalyzeList(List <string> list, string listname = "Various Files") { FileObjectCollection fileList = new FileObjectCollection(); TrackLister tracklist = new TrackLister(); MakeFile makeFile = new MakeFile(); ChapterGenerator chapterGet = new ChapterGenerator(); //ProgressState progressState = new ProgressState(); //fileList.folderPath = path; //Deprecated fileList.name = listname; //Deprecated progressState.listName = fileList.name; analyzeProgress = 1; analyzeProcessPercent = 0; foreach (string s in list) { FileObject file = new FileObject(s); analyzeProcessPercent = analyzeProgress.ToPercentage(list.Count); progressState.progressPercent = analyzeProcessPercent; progressState.fileName = file.filename; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); //Routine after splitting //Checks if current backgroundWorker operation is cancelled //Stops this program if true if (Analyze.backgroundWorker.CancellationPending) { return; } try { file = InfoDumper.infoDump(file); if (Program.hasFFmpeg) { file = InfoDumper.ffInfoDump(file); } } catch (Exception ex) { MessageBox.Show("Error:\r\n\r\n" + ex.Message, "Error"); } progressState.progressDetail = "Dumping MKV info..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); file = chapterGet.chapterDump(file); if (!String.IsNullOrEmpty(file.ffInfo)) { file = chapterGet.mediaDump(file); } if (!Config.Configure.includeMkvInfoOnFiles) { file.mkvInfo = null; } if (!Config.Configure.includeMediaInfoOnFiles) { file.ffInfo = null; } fileList.addFile(file); //For Diagnoses purposes only if (Config.Configure.diagnose >= 30) { Console.WriteLine("Chapter Atom count: {0}\n", file.chapterAtom.Count, file.mkvInfo); foreach (ChapterAtom chapter in file.chapterAtom) { { Console.WriteLine("File name: {0}\nChapter Number: {2}\nTime Start: {3}\nTime End: {4}\nSuid: {5}\n", file.filename, chapter.chapterInfo, chapter.chapterNum, chapter.timeStart, chapter.timeEnd, chapter.suid); } } } progressState.progressDetail = "Getting chapters' info..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); analyzeProgress++; } SuidLister suidList = getSuid(fileList); progressState.progressDetail = "Creating SUID list..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); fileList = tracklist.arrangeTrack(fileList, suidList, this); progressState.progressDetail = "Arranging new tracklist for every file..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); //For Diagnostic purposes only if (Config.Configure.diagnose >= 30) { foreach (Suid suid in suidList.suidList) { { Console.WriteLine("SUID filename: " + suid.fileName); Console.WriteLine("SUID: " + suid.suid); Console.WriteLine("\n"); } } Console.WriteLine("fileList.fileList.Count: " + fileList.fileList.Count + "\n"); foreach (FileObject file in fileList.fileList) { //Console.WriteLine("Merge Argument count: {0}\n", file.mergeArgument.Count); foreach (MergeArgument merge in file.mergeArgument) { Console.WriteLine("Merge Argument:\nFile name: {0}\nTime Code: {1}\nFile Argument: {2}\nChapter Number: {3}\n", file.filename, merge.timeCode, merge.fileName, merge.chapterNum); } foreach (TimeCode time in file.timeCode) { Console.WriteLine("Time Code Argument: {0}\n", time.timeCode); } foreach (DelArgument del in file.delArgument) { Console.WriteLine("Del Argument: {0}\n", del.fileName); } } } fileLists.Add(fileList); if (Config.Configure.doMakeXml) { makeFile.makeFile(fileList, this); progressState.progressDetail = "Dumping XML file..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); } if (Config.Configure.doMakeScript) { makeFile.makeXML(fileList, this); progressState.progressDetail = "Creating Merge Script..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); } }
/// <summary> /// Dumps MKVinfo's of every file for later use /// </summary> /// <param name="file">The FileObject to process.</param> /// <returns>The FileObject processed.</returns> public static FileObject infoDump(FileObject file) { if (file.extension == ".mkv") { /* * Use of using syntax is preferred. * Also, hidden window style is preferred. * */ ProcessStartInfo p = new ProcessStartInfo(Program.infoExe); p.Arguments = "\"" + file.fullpath + "\""; p.UseShellExecute = false; p.CreateNoWindow = true; p.WindowStyle = ProcessWindowStyle.Hidden; p.RedirectStandardOutput = true; //Process.Start(p); using (Process process = Process.Start(p)) { using (StreamReader reader = process.StandardOutput) { string output = reader.ReadToEnd(); file.addMkvInfo(output); } process.WaitForExit(); } } else { Console.WriteLine("Not an MKV file."); } return file; }
/// <summary> /// Checks if file extension is valid for merging/converting. /// </summary> /// <param name="file">The FileObject to process.</param> /// <returns>True if file extension is valid; else, false.</returns> public static bool ValidateExtension(FileObject file) { bool valid = false; //Temporary list of extensions; maybe replaced by a more proper global list in the future. string[] extensions = { ".mkv", ".mp4", ".mpeg", ".avi", ".wmv", ".aac", ".ogg", ".mp3", ".m4a", ".jpg", ".jpeg", ".png", ".bmp", ".tga" }; foreach (string extension in MediaData.extensions) { if (file.extension == extension) valid = true; else valid = false; } return valid; }
/// <summary> /// Processes files to create File Objects for the main tasks of this program. /// Every tasks are denoted on each comment lines inside the method. /// </summary> /// <param name="list">The list that contains the fullpaths of the actual files.</param> /// <param name="listname">Name for the FileObjectCollection to be created.</param> public void AnalyzeList(List<string> list, string listname = "Various Files") { FileObjectCollection fileList = new FileObjectCollection(); TrackLister tracklist = new TrackLister(); MakeFile makeFile = new MakeFile(); ChapterGenerator chapterGet = new ChapterGenerator(); //ProgressState progressState = new ProgressState(); //fileList.folderPath = path; //Deprecated fileList.name = listname; //Deprecated progressState.listName = fileList.name; analyzeProgress = 1; analyzeProcessPercent = 0; foreach (string s in list) { FileObject file = new FileObject(s); analyzeProcessPercent = analyzeProgress.ToPercentage(list.Count); progressState.progressPercent = analyzeProcessPercent; progressState.fileName = file.filename; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); //Routine after splitting //Checks if current backgroundWorker operation is cancelled //Stops this program if true if (Analyze.backgroundWorker.CancellationPending) { return; } try { file = InfoDumper.infoDump(file); if (Program.hasFFmpeg) file = InfoDumper.ffInfoDump(file); } catch (Exception ex) { MessageBox.Show("Error:\r\n\r\n" + ex.Message, "Error"); } progressState.progressDetail = "Dumping MKV info..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); file = chapterGet.chapterDump(file); if (!String.IsNullOrEmpty(file.ffInfo)) file = chapterGet.mediaDump(file); if (!Config.Configure.includeMkvInfoOnFiles) file.mkvInfo = null; if (!Config.Configure.includeMediaInfoOnFiles) file.ffInfo = null; fileList.addFile(file); //For Diagnoses purposes only if (Config.Configure.diagnose >= 30) { Console.WriteLine("Chapter Atom count: {0}\n", file.chapterAtom.Count, file.mkvInfo); foreach (ChapterAtom chapter in file.chapterAtom) { { Console.WriteLine("File name: {0}\nChapter Number: {2}\nTime Start: {3}\nTime End: {4}\nSuid: {5}\n", file.filename, chapter.chapterInfo, chapter.chapterNum, chapter.timeStart, chapter.timeEnd, chapter.suid); } } } progressState.progressDetail = "Getting chapters' info..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); analyzeProgress++; } SuidLister suidList = getSuid(fileList); progressState.progressDetail = "Creating SUID list..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); fileList = tracklist.arrangeTrack(fileList, suidList, this); progressState.progressDetail = "Arranging new tracklist for every file..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); //For Diagnostic purposes only if (Config.Configure.diagnose >= 30) { foreach (Suid suid in suidList.suidList) { { Console.WriteLine("SUID filename: " + suid.fileName); Console.WriteLine("SUID: " + suid.suid); Console.WriteLine("\n"); } } Console.WriteLine("fileList.fileList.Count: " + fileList.fileList.Count + "\n"); foreach (FileObject file in fileList.fileList) { //Console.WriteLine("Merge Argument count: {0}\n", file.mergeArgument.Count); foreach (MergeArgument merge in file.mergeArgument) { Console.WriteLine("Merge Argument:\nFile name: {0}\nTime Code: {1}\nFile Argument: {2}\nChapter Number: {3}\n", file.filename, merge.timeCode, merge.fileName, merge.chapterNum); } foreach (TimeCode time in file.timeCode) { Console.WriteLine("Time Code Argument: {0}\n", time.timeCode); } foreach (DelArgument del in file.delArgument) { Console.WriteLine("Del Argument: {0}\n", del.fileName); } } } fileLists.Add(fileList); if (Config.Configure.doMakeXml) { makeFile.makeFile(fileList, this); progressState.progressDetail = "Dumping XML file..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); } if (Config.Configure.doMakeScript) { makeFile.makeXML(fileList, this); progressState.progressDetail = "Creating Merge Script..."; Analyze.backgroundWorker.ReportProgress(progressArg, progressState); } }
/// <summary> /// Processes files to create File Objects for the main tasks of this program. /// Every tasks are denoted on each comment lines inside the method. /// </summary> /// <param name="list">The list that contains the fullpaths of the actual files.</param> /// <param name="listname">Name for the FileObjectCollection to be created.</param> /// <param name="processor">The Analyze object for progression report.</param> /// <param name="path">The path used as a working directory merge commands.</param> /// <param name="totalArguments">Optional. For progress report. The total number of lists to process.</param> public void processList(List<string> list, string listname, Analyze processor, string path = "C:\\", int totalArguments = 0) { FileObjectCollection fileList = new FileObjectCollection(); TrackLister tracklist = new TrackLister(); MakeFile makeFile = new MakeFile(); ChapterGenerator chapterGet = new ChapterGenerator(); ProgressState progressState = new ProgressState(); fileList.folderPath = path; fileList.name = listname; progressState.listName = fileList.name; progress = 1; processPercent = 0; foreach (string s in list) { progressState.progressDetail = "Creating file entry..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); FileObject file = new FileObject(s); processPercent = progress.ToPercentage(list.Count); progressState.progressPercent = processPercent; progressState.fileName = file.filename; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); //Routine after splitting //Checks if current backgroundWorker operation is cancelled //Stops this program if true if (Analyze.backgroundWorker.CancellationPending) { return; } if (file.extension == ".mkv") { try { file = InfoDumper.infoDump(file); } catch (Exception ex) { Program.Message("Error:\r\n\r\n" + ex.Message, "Error"); } progressState.progressDetail = "Dumping MKV info..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); file = chapterGet.chapterDump(file); if (!Config.Configure.includeMkvInfoOnFiles) file.mkvInfo = null; if (!Config.Configure.includeMediaInfoOnFiles) file.ffInfo = null; progressState.progressDetail = "Getting chapters' info..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); fileList.hasMKV = true; } if (Program.hasFFmpeg) { progressState.progressDetail = "Dumping media info..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); try { file = InfoDumper.ffInfoDump(file); } catch (Exception ex) { Program.Message("Error:\r\n\r\n" + ex.Message, "Error"); } if (!String.IsNullOrEmpty(file.ffInfo)) file = chapterGet.mediaDump(file); } fileList.addFile(file); progress++; } if (fileList.hasMKV) { SuidLister suidList = CreateSuidLister(fileList); progressState.progressDetail = "Creating SUID list..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); fileList = tracklist.arrangeTrack(fileList, suidList, processor); progressState.progressDetail = "Arranging new tracklist for every file..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); //For Diagnostic purposes only if (Config.Configure.diagnose >= 30) { foreach (Suid suid in suidList.suidList) { { Console.WriteLine("SUID filename: " + suid.fileName); Console.WriteLine("SUID: " + suid.suid); Console.WriteLine("\n"); } } Console.WriteLine("fileList.fileList.Count: " + fileList.fileList.Count + "\n"); foreach (FileObject file in fileList.fileList) { //Console.WriteLine("Merge Argument count: {0}\n", file.mergeArgument.Count); foreach (MergeArgument merge in file.mergeArgument) { Console.WriteLine("Merge Argument:\nFile name: {0}\nTime Code: {1}\nFile Argument: {2}\nChapter Number: {3}\n", file.filename, merge.timeCode, merge.fileName, merge.chapterNum); } foreach (TimeCode time in file.timeCode) { Console.WriteLine("Time Code Argument: {0}\n", time.timeCode); } foreach (DelArgument del in file.delArgument) { Console.WriteLine("Del Argument: {0}\n", del.fileName); } } } if (Config.Configure.doMakeScript) { makeFile.makeFile(fileList, processor); progressState.progressDetail = "Creating Merge Script..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); } } if (Config.Configure.doMakeXml) { makeFile.makeXML(fileList, processor); progressState.progressDetail = "Dumping XML file..."; Analyze.backgroundWorker.ReportProgress(processor.progressArg, progressState); } processor.fileLists.Add(fileList); }
/// <summary> /// Deprecated. Adds media informations to FileObjects using FFprobe. /// </summary> /// <param name="file">The FileObject processed by InfoDumper.ffProbeDump.</param> /// <returns>The FileObject with processed media informations.</returns> public FileObject probeMediaDump(FileObject file) { List<string> tracklists = new List<string>(); Match inputInfo = Regex.Match(file.ffInfo, @"Input #\d?, .*\r*\n([\s\S]*)"); file.mediaInfo.mediaStreams = new List<MediaStream>(); file.mediaInfo.inputInfo = file.ffInfo.Replace("\r", ""); //file.mediaInfo.duration = Regex.Match(file.mediaInfo.inputInfo, @" Duration\: (\d\d\:\d\d\:\d\d\.\d\d)(.*)").Groups[1].Value; //file.mediaInfo.bitratekb = int.Parse(Regex.Match(file.mediaInfo.inputInfo, @"bitrate: (\d+) kb\/s").Groups[1].Value); MatchCollection streams = Regex.Matches(file.mediaInfo.inputInfo, @"\[STREAM\]\n([\s\S]+?)\n\[.+STREAM\]"); foreach (Match stream in streams) { MediaStream mediastream = new MediaStream(); mediastream.mediaType = (MediaType)Enum.Parse(typeof(MediaType), Regex.Match(stream.Value, @"codec_type=(.*)").Groups[1].Value, true); mediastream.codecInfo = stream.Groups[1].Value; mediastream.codec = Regex.Match(stream.Value, @"codec_long_name=(.*)").Groups[1].Value; //mediastream.metaData = stream.Groups[3].Value; //to be removed; metadata is no longer provided as is, as ffprobe is used. file.mediaInfo.mediaStreams.Add(mediastream); } return file; }
/// <summary> /// Add a file that represents this chapter's externally linked SUID. /// </summary> /// <param name="file">The representing FileObject.</param> public void addSuidFileName(FileObject file) { this.suidFileName = file.filename; this.suidFullPath = file.fullpath; }
/// <summary> /// Adds media informations to FileObjects. /// </summary> /// <param name="file">The FileObject processed by InfoDumper.ffInfoDump.</param> /// <returns>The FileObject with processed media informations.</returns> public FileObject mediaDump(FileObject file) { List<string> tracklists = new List<string>(); Match inputInfo = Regex.Match(file.ffInfo, @"Input #\d?, .*\r*\n([\s\S]*)(?:At least one.+)"); file.mediaInfo.mediaStreams = new List<MediaStream>(); file.mediaInfo.inputInfo = inputInfo.Value.Replace("\r",""); file.mediaInfo.duration = Regex.Match(file.mediaInfo.inputInfo, @" Duration\: (\d\d\:\d\d\:\d\d\.\d\d)(.*)").Groups[1].Value; file.mediaInfo.bitratekb = int.Parse(Regex.Match(file.mediaInfo.inputInfo, @"bitrate: (\d+) kb\/s").Groups[1].Value); MatchCollection streams = Regex.Matches(file.mediaInfo.inputInfo, @" Stream #\d?\:\d?(?:(?:\S+)*)\: (.+)\: (.+)\r*\n((?: Metadata:\r*\n(?: .*)*)*)"); foreach (Match stream in streams) { MediaStream mediastream = new MediaStream(); mediastream.mediaType = (MediaType) Enum.Parse(typeof(MediaType), stream.Groups[1].Value, true); mediastream.codecInfo = stream.Groups[2].Value; mediastream.codec = stream.Groups[2].Value.Split(',')[0]; mediastream.metaData = stream.Groups[3].Value; file.mediaInfo.mediaStreams.Add(mediastream); } if (!Config.Configure.includeMediaInfoOnFiles) file.mediaInfo.inputInfo = null; return file; }
/// <summary> /// Add a file that represents this chapter's externally linked SUID. /// </summary> /// <param name="file">The representing FileObject.</param> public void addSuidFileName(FileObject file) { this.suidFileName = file.filename; this.suidFullPath = file.fullpath; }