private static SvtTestSuccess?ParseOutputLinesToTest(List <string> lines) { SvtTestSuccess?output = null; Regex summaryLineRegex = new Regex("SUMMARY [-]* Channel \\d [-]*"); try { //If there is a summary line, we probably have a successful test string?summaryLine = lines.Find(l => summaryLineRegex.IsMatch(l)); if (summaryLine != null) { int summaryLineStart = lines.IndexOf(summaryLine); IEnumerable <string> summaryLines = lines.GetRange(summaryLineStart, lines.Count - summaryLineStart); var statLine2 = summaryLines.ElementAt(6).ParseNoWhiteSpace(); output = new SvtTestSuccess(); try { output.ClipNumber = int.Parse(Regex.Replace(lines[1], InputLineFfmpeg.ToString(), "").Replace(".mkv':", "")); } catch { System.Console.WriteLine(("Cannot parse clip number from line: " + lines.ToArray()[1] + "| parse input: " + Regex.Replace(lines[1], InputLineFfmpeg.ToString(), "").Replace(".mkv':", ""))); } //Sometimes, I move the videos and logs into a different directory. string possibleOutputPath = ""; try { possibleOutputPath = lines.Last(l => l.Contains("File finished: ")).ParseNoWhiteSpace()[2]; if (!File.Exists(possibleOutputPath)) { System.Console.WriteLine(possibleOutputPath + " does not exist. Searching manually for real output path..."); var directories = Directory.GetDirectories(Path.GetDirectoryName(possibleOutputPath)); if (directories.Length == 0) { output.OutputPath = possibleOutputPath; } else { string newPossiblePath = Path.Combine(Path.GetDirectoryName(possibleOutputPath) !, "clip", Path.GetFileName(possibleOutputPath)); if (File.Exists(newPossiblePath)) { output.OutputPath = newPossiblePath; } else { output.OutputPath = possibleOutputPath; } } } else { output.OutputPath = possibleOutputPath; } } catch (Exception ex) { System.Console.WriteLine("Exception occurred setting output path."); System.Console.WriteLine(ex.ToString()); System.Console.WriteLine(ex.StackTrace?.ToString()); output.OutputPath = output.OutputPath ?? possibleOutputPath; } try { output.FileSize = uint.Parse(summaryLines.ElementAt(2).ParseNoWhiteSpace()[3]); output.Bitrate = double.Parse(summaryLines.ElementAt(2).ParseNoWhiteSpace()[4]); output.AvgQP = double.Parse(statLine2[0]); output.AvgYPSNR = double.Parse(summaryLines.ElementAt(6).ParseNoWhiteSpace()[1]); output.OverallYPSNR = double.Parse(statLine2[5]); output.AvgSpeed = double.Parse(summaryLines.ElementAt(10).ParseNoWhiteSpace()[2]); output.EncodingTime = TimeSpan.FromMilliseconds(double.Parse(summaryLines.ElementAt(11).ParseNoWhiteSpace()[3])); output.VMAF = double.Parse(summaryLines.First(l => l.Contains("VMAF score = ")).Replace("VMAF score = ", "")); } catch (Exception ex) { System.Console.WriteLine("============="); summaryLines.ToList().ForEach(l => System.Console.WriteLine(l)); System.Console.WriteLine("============="); System.Console.WriteLine(summaryLines.ElementAt(2).ParseNoWhiteSpace()[3]); System.Console.WriteLine(summaryLines.ElementAt(6).ParseNoWhiteSpace()[1]); System.Console.WriteLine(summaryLines.ElementAt(10).ParseNoWhiteSpace()[2]); System.Console.WriteLine(summaryLines.ElementAt(11).ParseNoWhiteSpace()[3]); System.Console.WriteLine("============="); throw ex; } output.AdditionalCommands = summaryLines.Last(l => l.Contains("Cmmd finished: ")).Replace("Cmmd finished: ", ""); if (File.Exists(output.OutputPath)) { FileInfo fileInfo = new FileInfo(output.OutputPath); if (fileInfo.Directory.Name == "clip") { string masterTestDirectory = Path.GetDirectoryName(fileInfo.DirectoryName) !; string realLogPath = Path.Combine(masterTestDirectory, "logs", Path.GetFileName(output.OutputPath)) + ".log"; output.FrameLogs = GetPictureStatsFromStatFile(realLogPath); } else { output.FrameLogs = GetPictureStatsFromStatFile(output.OutputPath + ".log"); } } } } catch (FormatException fe) { System.Console.WriteLine(fe.StackTrace); throw fe; } catch (Exception ex) { throw ex; } return(output); }
public bool AddSuccessfulTest(SvtTestSuccess test) { System.Console.WriteLine(test.ToString()); return(true); }
public bool AddSuccessfulTest(SvtTestSuccess test) { throw new NotImplementedException(); }