public void JoinSameCodec(TestFiles.TypeEnum type) { var output = Path.Combine(this.tempOutputDir, "concated_video" + TestFiles.Exentsions[type]); var slides = new[] { TestFiles.SlideEnum.Nr1Red, TestFiles.SlideEnum.Nr2Blue, TestFiles.SlideEnum.Nr3Green, }; var files = slides.Select(slide => TestFiles.GetTestVideo(slide, type)); foreach (var file in files) { Assert.That(File.Exists(file), "input test must exists"); } var script = this.preparer.ConcateClips(output, files.ToArray()); Console.Out.WriteLine("Script"); Console.Out.WriteLine(script); var process = PowershellExecutor.Execute(script); Assert.That(File.Exists(output), "output file exists"); Assert.That(Helper.DetermineSlide(TimeSpan.FromSeconds(2.5), output), Is.EqualTo(TestFiles.SlideEnum.Nr1Red)); Assert.That(Helper.DetermineSlide(TimeSpan.FromSeconds(5 + 2.5), output), Is.EqualTo(TestFiles.SlideEnum.Nr2Blue)); Assert.That(Helper.DetermineSlide(TimeSpan.FromSeconds(10 + 2.5), output), Is.EqualTo(TestFiles.SlideEnum.Nr3Green)); }
public static TestFiles.SlideEnum DetermineSlide(TimeSpan position, string file) { var directory = TestContext.CurrentContext.TestDirectory; var preparer = new PowershellPreparer($@"{directory}\..\..\FFmpegStatic\ffmpeg.exe"); string image = Path.GetTempFileName() + ".png"; var script = preparer.CaptureImage(file, image, position); var process = PowershellExecutor.Execute(script); var color = GetTestImageColor(image); if (color.R > 200 && color.G < 10 && color.B < 10) { return(TestFiles.SlideEnum.Nr1Red); } if (color.R < 10 && color.G > 200 && color.B < 10) { return(TestFiles.SlideEnum.Nr3Green); } if (color.R < 10 && color.G < 10 && color.B > 200) { return(TestFiles.SlideEnum.Nr2Blue); } throw new Exception(); }
public void CaptureImage(byte r, byte g, byte b, int ms) { var file = Path.Combine(this.tempOutputDir, "picture.png"); TimeSpan pos = TimeSpan.FromMilliseconds(ms); var script = this.preparer.CaptureImage(TestFiles.Slides, file, pos); Console.Out.WriteLine("Script"); Console.Out.WriteLine(script); var process = PowershellExecutor.Execute(script); Assert.That(File.Exists(file), "output file exists"); Color pixelColor = Helper.GetTestImageColor(file); Assert.That(pixelColor.A, Is.EqualTo(255).Within(ColorTolerance).Percent); Assert.That(pixelColor.R, Is.EqualTo(r).Within(ColorTolerance).Percent); Assert.That(pixelColor.G, Is.EqualTo(g).Within(ColorTolerance).Percent); Assert.That(pixelColor.B, Is.EqualTo(b).Within(ColorTolerance).Percent); }