mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 01:55:45 +00:00
Add more missing tests
This commit is contained in:
parent
55d526ce92
commit
f0f60c8bd8
2 changed files with 89 additions and 0 deletions
|
|
@ -93,6 +93,14 @@ public class ArgumentBuilderTest
|
||||||
Assert.AreEqual("-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\"", str);
|
Assert.AreEqual("-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\"", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DemuxConcat()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromDemuxConcatInput(_concatFiles).OutputToFile("output.mp4", false).Arguments;
|
||||||
|
Assert.Contains("-f concat -safe 0 -i", str);
|
||||||
|
Assert.Contains("\"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Copy_Audio()
|
public void Builder_BuildString_Copy_Audio()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -589,6 +589,19 @@ public class VideoTest
|
||||||
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
[OsSpecificTestMethod(OsPlatforms.Windows)]
|
||||||
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
|
public async Task Video_SnapshotAsync_InMemory_SystemDrawingCommon()
|
||||||
|
{
|
||||||
|
using var bitmap = await FFMpegImage.SnapshotAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
||||||
|
|
||||||
|
var input = await FFProbe.AnalyseAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream!.Width, bitmap.Width);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream.Height, bitmap.Height);
|
||||||
|
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Snapshot_InMemory_SkiaSharp()
|
public void Video_Snapshot_InMemory_SkiaSharp()
|
||||||
|
|
@ -602,6 +615,19 @@ public class VideoTest
|
||||||
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
|
public async Task Video_SnapshotAsync_InMemory_SkiaSharp()
|
||||||
|
{
|
||||||
|
using var bitmap = await Extensions.SkiaSharp.FFMpegImage.SnapshotAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
||||||
|
|
||||||
|
var input = await FFProbe.AnalyseAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream!.Width, bitmap.Width);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream.Height, bitmap.Height);
|
||||||
|
// Note: The resulting ColorType is dependent on the execution environment and therefore not assessed,
|
||||||
|
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Snapshot_Png_PersistSnapshot()
|
public void Video_Snapshot_Png_PersistSnapshot()
|
||||||
|
|
@ -617,6 +643,21 @@ public class VideoTest
|
||||||
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
|
public async Task Video_SnapshotAsync_Png_PersistSnapshot()
|
||||||
|
{
|
||||||
|
using var outputPath = new TemporaryFile("out.png");
|
||||||
|
var input = await FFProbe.AnalyseAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
||||||
|
|
||||||
|
await FFMpeg.SnapshotAsync(TestResources.Mp4Video, outputPath, cancellationToken: TestContext.CancellationToken);
|
||||||
|
|
||||||
|
var analysis = FFProbe.Analyse(outputPath);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream!.Width, analysis.PrimaryVideoStream!.Width);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream.Height, analysis.PrimaryVideoStream!.Height);
|
||||||
|
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Snapshot_Jpg_PersistSnapshot()
|
public void Video_Snapshot_Jpg_PersistSnapshot()
|
||||||
|
|
@ -780,6 +821,46 @@ public class VideoTest
|
||||||
Assert.AreEqual(input.PrimaryVideoStream!.Height, result.PrimaryVideoStream!.Height);
|
Assert.AreEqual(input.PrimaryVideoStream!.Height, result.PrimaryVideoStream!.Height);
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
|
public void Video_Convert_Webm()
|
||||||
|
{
|
||||||
|
using var outputPath = new TemporaryFile("out.webm");
|
||||||
|
|
||||||
|
var success = FFMpeg.Convert(TestResources.Mp4Video, outputPath, VideoType.WebM);
|
||||||
|
Assert.IsTrue(success);
|
||||||
|
Assert.IsTrue(File.Exists(outputPath));
|
||||||
|
|
||||||
|
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
||||||
|
var result = FFProbe.Analyse(outputPath);
|
||||||
|
Assert.AreEqual(input.Duration.Days, result.Duration.Days);
|
||||||
|
Assert.AreEqual(input.Duration.Hours, result.Duration.Hours);
|
||||||
|
Assert.AreEqual(input.Duration.Minutes, result.Duration.Minutes);
|
||||||
|
Assert.AreEqual(input.Duration.Seconds, result.Duration.Seconds);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream!.Height, result.PrimaryVideoStream!.Height);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
|
public void Video_Convert_Ogv()
|
||||||
|
{
|
||||||
|
using var outputPath = new TemporaryFile("out.ogv");
|
||||||
|
|
||||||
|
var success = FFMpeg.Convert(TestResources.Mp4Video, outputPath, VideoType.Ogv);
|
||||||
|
Assert.IsTrue(success);
|
||||||
|
Assert.IsTrue(File.Exists(outputPath));
|
||||||
|
|
||||||
|
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
||||||
|
var result = FFProbe.Analyse(outputPath);
|
||||||
|
Assert.AreEqual(input.Duration.Days, result.Duration.Days);
|
||||||
|
Assert.AreEqual(input.Duration.Hours, result.Duration.Hours);
|
||||||
|
Assert.AreEqual(input.Duration.Minutes, result.Duration.Minutes);
|
||||||
|
Assert.AreEqual(input.Duration.Seconds, result.Duration.Seconds);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream!.Height, result.PrimaryVideoStream!.Height);
|
||||||
|
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(2 * BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(2 * BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue