mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 01:55:45 +00:00
Update tests to new syntax
This commit is contained in:
parent
31e30c1eb7
commit
d3d810ecd7
9 changed files with 162 additions and 172 deletions
|
|
@ -670,7 +670,7 @@ namespace FFMpegCore.Test
|
|||
try
|
||||
{
|
||||
// Act & Assert
|
||||
Assert.ThrowsException<FileNotFoundException>(() => argument.Pre());
|
||||
Assert.ThrowsExactly<FileNotFoundException>(() => argument.Pre());
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -691,7 +691,7 @@ namespace FFMpegCore.Test
|
|||
};
|
||||
var argument = new MultiInputArgument(true, filePaths);
|
||||
// Act & Assert
|
||||
Assert.ThrowsException<FileNotFoundException>(() => argument.Pre());
|
||||
Assert.ThrowsExactly<FileNotFoundException>(() => argument.Pre());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1
FFMpegCore.Test/Assembly.cs
Normal file
1
FFMpegCore.Test/Assembly.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
[assembly: Parallelize]
|
||||
|
|
@ -3,7 +3,6 @@ using FFMpegCore.Exceptions;
|
|||
using FFMpegCore.Extend;
|
||||
using FFMpegCore.Pipes;
|
||||
using FFMpegCore.Test.Resources;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace FFMpegCore.Test
|
||||
{
|
||||
|
|
@ -18,8 +17,8 @@ namespace FFMpegCore.Test
|
|||
FFMpeg.Mute(TestResources.Mp4Video, outputFile);
|
||||
var analysis = FFProbe.Analyse(outputFile);
|
||||
|
||||
Assert.IsTrue(analysis.VideoStreams.Any());
|
||||
Assert.IsTrue(!analysis.AudioStreams.Any());
|
||||
Assert.IsNotEmpty(analysis.VideoStreams);
|
||||
Assert.IsEmpty(analysis.AudioStreams);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -30,9 +29,10 @@ namespace FFMpegCore.Test
|
|||
FFMpeg.ExtractAudio(TestResources.Mp4Video, outputFile);
|
||||
var analysis = FFProbe.Analyse(outputFile);
|
||||
|
||||
Assert.IsTrue(!analysis.VideoStreams.Any());
|
||||
Assert.IsTrue(analysis.AudioStreams.Any());
|
||||
Assert.IsNotEmpty(analysis.AudioStreams);
|
||||
Assert.IsEmpty(analysis.VideoStreams);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Audio_FromRaw()
|
||||
{
|
||||
|
|
@ -65,19 +65,19 @@ namespace FFMpegCore.Test
|
|||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
FFMpeg.PosterWithAudio(TestResources.PngImage, TestResources.Mp3Audio, outputFile);
|
||||
var analysis = FFProbe.Analyse(TestResources.Mp3Audio);
|
||||
Assert.IsTrue(analysis.Duration.TotalSeconds > 0);
|
||||
Assert.IsGreaterThan(0, analysis.Duration.TotalSeconds);
|
||||
Assert.IsTrue(File.Exists(outputFile));
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var samples = new List<IAudioSample>
|
||||
{
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
};
|
||||
|
||||
var audioSamplesSource = new RawAudioPipeSource(samples)
|
||||
|
|
@ -95,15 +95,15 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToLibVorbis_Args_Pipe()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var samples = new List<IAudioSample>
|
||||
{
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
};
|
||||
|
||||
var audioSamplesSource = new RawAudioPipeSource(samples)
|
||||
|
|
@ -121,15 +121,15 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Audio_ToAAC_Args_Pipe_Async()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var samples = new List<IAudioSample>
|
||||
{
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
};
|
||||
|
||||
var audioSamplesSource = new RawAudioPipeSource(samples)
|
||||
|
|
@ -147,15 +147,15 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_ValidDefaultConfiguration()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var samples = new List<IAudioSample>
|
||||
{
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper(new byte[] { 0, 0 }),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
new PcmAudioSampleWrapper([0, 0]),
|
||||
};
|
||||
|
||||
var audioSamplesSource = new RawAudioPipeSource(samples);
|
||||
|
|
@ -168,7 +168,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_InvalidChannels()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -178,14 +178,14 @@ namespace FFMpegCore.Test
|
|||
Channels = 0,
|
||||
};
|
||||
|
||||
var ex = Assert.ThrowsException<FFMpegException>(() => FFMpegArguments
|
||||
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_InvalidFormat()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -195,14 +195,14 @@ namespace FFMpegCore.Test
|
|||
Format = "s8le",
|
||||
};
|
||||
|
||||
var ex = Assert.ThrowsException<FFMpegException>(() => FFMpegArguments
|
||||
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_InvalidSampleRate()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -212,14 +212,14 @@ namespace FFMpegCore.Test
|
|||
SampleRate = 0,
|
||||
};
|
||||
|
||||
var ex = Assert.ThrowsException<FFMpegException>(() => FFMpegArguments
|
||||
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMono()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -233,11 +233,11 @@ namespace FFMpegCore.Test
|
|||
var mediaAnalysis = FFProbe.Analyse(outputFile);
|
||||
|
||||
Assert.IsTrue(success);
|
||||
Assert.AreEqual(1, mediaAnalysis.AudioStreams.Count);
|
||||
Assert.HasCount(1, mediaAnalysis.AudioStreams);
|
||||
Assert.AreEqual("mono", mediaAnalysis.PrimaryAudioStream!.ChannelLayout);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMonoNoDefinitions()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -251,35 +251,35 @@ namespace FFMpegCore.Test
|
|||
var mediaAnalysis = FFProbe.Analyse(outputFile);
|
||||
|
||||
Assert.IsTrue(success);
|
||||
Assert.AreEqual(1, mediaAnalysis.AudioStreams.Count);
|
||||
Assert.HasCount(1, mediaAnalysis.AudioStreams);
|
||||
Assert.AreEqual("mono", mediaAnalysis.PrimaryAudioStream!.ChannelLayout);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMonoChannelsToOutputDefinitionsMismatch()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var ex = Assert.ThrowsException<ArgumentException>(() => FFMpegArguments.FromFileInput(TestResources.Mp3Audio)
|
||||
Assert.ThrowsExactly<ArgumentException>(() => FFMpegArguments.FromFileInput(TestResources.Mp3Audio)
|
||||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.Pan(1, "c0=c0", "c1=c1")))
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMonoChannelsLayoutToOutputDefinitionsMismatch()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var ex = Assert.ThrowsException<FFMpegException>(() => FFMpegArguments.FromFileInput(TestResources.Mp3Audio)
|
||||
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments.FromFileInput(TestResources.Mp3Audio)
|
||||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.Pan("mono", "c0=c0", "c1=c1")))
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_DynamicNormalizer_WithDefaultValues()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -293,7 +293,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_DynamicNormalizer_WithNonDefaultValues()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -308,7 +308,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[DataTestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
[DataRow(2)]
|
||||
[DataRow(32)]
|
||||
[DataRow(8)]
|
||||
|
|
@ -316,7 +316,7 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
var ex = Assert.ThrowsException<ArgumentOutOfRangeException>(() => FFMpegArguments
|
||||
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp3Audio)
|
||||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace FFMpegCore.Test
|
|||
[TestMethod]
|
||||
public void Options_Defaults_Configured()
|
||||
{
|
||||
Assert.AreEqual(new FFOptions().BinaryFolder, $"");
|
||||
Assert.AreEqual("", new FFOptions().BinaryFolder);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -35,8 +35,8 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = "Whatever" });
|
||||
Assert.AreEqual(
|
||||
GlobalFFOptions.Current.BinaryFolder,
|
||||
"Whatever"
|
||||
"Whatever",
|
||||
GlobalFFOptions.Current.BinaryFolder
|
||||
);
|
||||
}
|
||||
finally
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
var frameAnalysis = FFProbe.GetFrames(TestResources.WebmVideo);
|
||||
|
||||
Assert.AreEqual(90, frameAnalysis.Frames.Count);
|
||||
Assert.HasCount(90, frameAnalysis.Frames);
|
||||
Assert.IsTrue(frameAnalysis.Frames.All(f => f.PixelFormat == "yuv420p"));
|
||||
Assert.IsTrue(frameAnalysis.Frames.All(f => f.Height == 360));
|
||||
Assert.IsTrue(frameAnalysis.Frames.All(f => f.Width == 640));
|
||||
|
|
@ -32,7 +32,7 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
var frameAnalysis = await FFProbe.GetFramesAsync(TestResources.WebmVideo);
|
||||
|
||||
Assert.AreEqual(90, frameAnalysis.Frames.Count);
|
||||
Assert.HasCount(90, frameAnalysis.Frames);
|
||||
Assert.IsTrue(frameAnalysis.Frames.All(f => f.PixelFormat == "yuv420p"));
|
||||
Assert.IsTrue(frameAnalysis.Frames.All(f => f.Height == 360));
|
||||
Assert.IsTrue(frameAnalysis.Frames.All(f => f.Width == 640));
|
||||
|
|
@ -44,9 +44,9 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
var packetAnalysis = await FFProbe.GetPacketsAsync(TestResources.WebmVideo);
|
||||
var packets = packetAnalysis.Packets;
|
||||
Assert.AreEqual(96, packets.Count);
|
||||
Assert.HasCount(96, packets);
|
||||
Assert.IsTrue(packets.All(f => f.CodecType == "video"));
|
||||
Assert.IsTrue(packets[0].Flags.StartsWith("K_"));
|
||||
Assert.StartsWith("K_", packets[0].Flags);
|
||||
Assert.AreEqual(1362, packets.Last().Size);
|
||||
}
|
||||
|
||||
|
|
@ -55,9 +55,9 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
var packets = FFProbe.GetPackets(TestResources.WebmVideo).Packets;
|
||||
|
||||
Assert.AreEqual(96, packets.Count);
|
||||
Assert.HasCount(96, packets);
|
||||
Assert.IsTrue(packets.All(f => f.CodecType == "video"));
|
||||
Assert.IsTrue(packets[0].Flags.StartsWith("K_"));
|
||||
Assert.StartsWith("K_", packets[0].Flags);
|
||||
Assert.AreEqual(1362, packets.Last().Size);
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
var packets = FFProbe.GetPackets(TestResources.Mp4Video).Packets;
|
||||
|
||||
Assert.AreEqual(216, packets.Count);
|
||||
Assert.HasCount(216, packets);
|
||||
var actual = packets.Select(f => f.CodecType).Distinct().ToList();
|
||||
var expected = new List<string> { "audio", "video" };
|
||||
CollectionAssert.AreEquivalent(expected, actual);
|
||||
|
|
@ -75,7 +75,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(141, packets.Count(t => t.CodecType == "audio"));
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[TestMethod]
|
||||
[DataRow("0:00:03.008000", 0, 0, 0, 3, 8)]
|
||||
[DataRow("05:12:59.177", 0, 5, 12, 59, 177)]
|
||||
[DataRow("149:07:50.911750", 6, 5, 7, 50, 911)]
|
||||
|
|
@ -105,7 +105,7 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
var info = FFProbe.Analyse(TestResources.Mp4Video);
|
||||
Assert.AreEqual(3, info.Duration.Seconds);
|
||||
Assert.AreEqual(0, info.Chapters.Count);
|
||||
Assert.IsEmpty(info.Chapters);
|
||||
|
||||
Assert.AreEqual("5.1", info.PrimaryAudioStream!.ChannelLayout);
|
||||
Assert.AreEqual(6, info.PrimaryAudioStream.Channels);
|
||||
|
|
@ -140,9 +140,11 @@ namespace FFMpegCore.Test
|
|||
public void Probe_Rotation()
|
||||
{
|
||||
var info = FFProbe.Analyse(TestResources.Mp4Video);
|
||||
Assert.IsNotNull(info.PrimaryVideoStream);
|
||||
Assert.AreEqual(0, info.PrimaryVideoStream.Rotation);
|
||||
|
||||
info = FFProbe.Analyse(TestResources.Mp4VideoRotation);
|
||||
Assert.IsNotNull(info.PrimaryVideoStream);
|
||||
Assert.AreEqual(90, info.PrimaryVideoStream.Rotation);
|
||||
}
|
||||
|
||||
|
|
@ -150,20 +152,23 @@ namespace FFMpegCore.Test
|
|||
public void Probe_Rotation_Negative_Value()
|
||||
{
|
||||
var info = FFProbe.Analyse(TestResources.Mp4VideoRotationNegative);
|
||||
Assert.IsNotNull(info.PrimaryVideoStream);
|
||||
Assert.AreEqual(-90, info.PrimaryVideoStream.Rotation);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Async_Success()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.Mp4Video);
|
||||
Assert.AreEqual(3, info.Duration.Seconds);
|
||||
Assert.IsNotNull(info.PrimaryVideoStream);
|
||||
Assert.AreEqual(8, info.PrimaryVideoStream.BitDepth);
|
||||
// This video's audio stream is AAC, which is lossy, so bit depth is meaningless.
|
||||
Assert.IsNotNull(info.PrimaryAudioStream);
|
||||
Assert.IsNull(info.PrimaryAudioStream.BitDepth);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Probe_Success_FromStream()
|
||||
{
|
||||
using var stream = File.OpenRead(TestResources.WebmVideo);
|
||||
|
|
@ -173,7 +178,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsNull(info.PrimaryAudioStream);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_FromStream_Async()
|
||||
{
|
||||
await using var stream = File.OpenRead(TestResources.WebmVideo);
|
||||
|
|
@ -181,7 +186,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(3, info.Duration.Seconds);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Probe_HDR()
|
||||
{
|
||||
var info = FFProbe.Analyse(TestResources.HdrVideo);
|
||||
|
|
@ -193,29 +198,29 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("bt2020", info.PrimaryVideoStream.ColorPrimaries);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_Subtitle_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.SrtSubtitle);
|
||||
Assert.IsNotNull(info.PrimarySubtitleStream);
|
||||
Assert.AreEqual(1, info.SubtitleStreams.Count);
|
||||
Assert.AreEqual(0, info.AudioStreams.Count);
|
||||
Assert.AreEqual(0, info.VideoStreams.Count);
|
||||
Assert.HasCount(1, info.SubtitleStreams);
|
||||
Assert.IsEmpty(info.AudioStreams);
|
||||
Assert.IsEmpty(info.VideoStreams);
|
||||
// BitDepth is meaningless for subtitles
|
||||
Assert.IsNull(info.SubtitleStreams[0].BitDepth);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_Disposition_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.Mp4Video);
|
||||
Assert.IsNotNull(info.PrimaryAudioStream);
|
||||
Assert.IsNotNull(info.PrimaryAudioStream.Disposition);
|
||||
Assert.AreEqual(true, info.PrimaryAudioStream.Disposition["default"]);
|
||||
Assert.AreEqual(false, info.PrimaryAudioStream.Disposition["forced"]);
|
||||
Assert.IsTrue(info.PrimaryAudioStream.Disposition["default"]);
|
||||
Assert.IsFalse(info.PrimaryAudioStream.Disposition["forced"]);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_Mp3AudioBitDepthNull_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.Mp3Audio);
|
||||
|
|
@ -224,7 +229,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsNull(info.PrimaryAudioStream.BitDepth);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_VocAudioBitDepth_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.AiffAudio);
|
||||
|
|
@ -232,16 +237,18 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(16, info.PrimaryAudioStream.BitDepth);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_MkvVideoBitDepth_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.MkvVideo);
|
||||
Assert.IsNotNull(info.PrimaryAudioStream);
|
||||
Assert.IsNotNull(info.PrimaryVideoStream);
|
||||
Assert.AreEqual(8, info.PrimaryVideoStream.BitDepth);
|
||||
|
||||
Assert.IsNotNull(info.PrimaryAudioStream);
|
||||
Assert.IsNull(info.PrimaryAudioStream.BitDepth);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_24BitWavBitDepth_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.Wav24Bit);
|
||||
|
|
@ -249,7 +256,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(24, info.PrimaryAudioStream.BitDepth);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
[TestMethod, Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Probe_Success_32BitWavBitDepth_Async()
|
||||
{
|
||||
var info = await FFProbe.AnalyseAsync(TestResources.Wav32Bit);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace FFMpegCore.Test
|
|||
public void PixelFormats_Enumerate()
|
||||
{
|
||||
var formats = FFMpeg.GetPixelFormats();
|
||||
Assert.IsTrue(formats.Count > 0);
|
||||
Assert.IsNotEmpty(formats);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -35,7 +35,7 @@ namespace FFMpegCore.Test
|
|||
[TestMethod]
|
||||
public void PixelFormats_GetNotExisting()
|
||||
{
|
||||
Assert.ThrowsException<FFMpegException>(() => FFMpeg.GetPixelFormat("yuv420pppUnknown"));
|
||||
Assert.ThrowsExactly<FFMpegException>(() => FFMpeg.GetPixelFormat("yuv420pppUnknown"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace FFMpegCore.Test.Utilities;
|
||||
|
||||
public class WindowsOnlyDataTestMethod : DataTestMethodAttribute
|
||||
{
|
||||
public override TestResult[] Execute(ITestMethod testMethod)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
var message = $"Test not executed on other platforms than Windows";
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
new TestResult { Outcome = UnitTestOutcome.Inconclusive, TestFailureException = new AssertInconclusiveException(message) }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return base.Execute(testMethod);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,29 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace FFMpegCore.Test.Utilities;
|
||||
|
||||
public class WindowsOnlyTestMethod : TestMethodAttribute
|
||||
{
|
||||
public override TestResult[] Execute(ITestMethod testMethod)
|
||||
public WindowsOnlyTestMethod([CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
|
||||
: base(callerFilePath, callerLineNumber)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<TestResult[]> ExecuteAsync(ITestMethod testMethod)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
var message = $"Test not executed on other platforms than Windows";
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
return
|
||||
[
|
||||
new TestResult { Outcome = UnitTestOutcome.Inconclusive, TestFailureException = new AssertInconclusiveException(message) }
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return base.Execute(testMethod);
|
||||
return await base.ExecuteAsync(testMethod);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ using FFMpegCore.Exceptions;
|
|||
using FFMpegCore.Pipes;
|
||||
using FFMpegCore.Test.Resources;
|
||||
using FFMpegCore.Test.Utilities;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace FFMpegCore.Test
|
||||
{
|
||||
|
|
@ -17,7 +16,7 @@ namespace FFMpegCore.Test
|
|||
{
|
||||
private const int BaseTimeoutMilliseconds = 15_000;
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToOGV()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Ogv.Extension}");
|
||||
|
|
@ -29,7 +28,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -41,7 +40,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_YUV444p()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -54,10 +53,10 @@ namespace FFMpegCore.Test
|
|||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
var analysis = FFProbe.Analyse(outputFile);
|
||||
Assert.IsTrue(analysis.VideoStreams.First().PixelFormat == "yuv444p");
|
||||
Assert.AreEqual("yuv444p", analysis.VideoStreams.First().PixelFormat);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -70,7 +69,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToH265_MKV_Args()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out.mkv");
|
||||
|
|
@ -84,12 +83,12 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyDataTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(System.Drawing.Imaging.PixelFormat.Format24bppRgb)]
|
||||
[DataRow(System.Drawing.Imaging.PixelFormat.Format32bppArgb)]
|
||||
public void Video_ToMP4_Args_Pipe_WindowsOnly(System.Drawing.Imaging.PixelFormat pixelFormat) => Video_ToMP4_Args_Pipe_Internal(pixelFormat);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(SkiaSharp.SKColorType.Rgb565)]
|
||||
[DataRow(SkiaSharp.SKColorType.Bgra8888)]
|
||||
public void Video_ToMP4_Args_Pipe(SkiaSharp.SKColorType pixelFormat) => Video_ToMP4_Args_Pipe_Internal(pixelFormat);
|
||||
|
|
@ -108,10 +107,10 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentImageSizes_WindowsOnly() => Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentImageSizes() => Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(SkiaSharp.SKColorType.Rgb565);
|
||||
|
||||
private static void Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(dynamic pixelFormat)
|
||||
|
|
@ -125,7 +124,7 @@ namespace FFMpegCore.Test
|
|||
};
|
||||
|
||||
var videoFramesSource = new RawVideoPipeSource(frames);
|
||||
var ex = Assert.ThrowsException<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
Assert.ThrowsExactly<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
|
|
@ -133,10 +132,10 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_WindowsOnly_Async() => await Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_Async() => await Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(SkiaSharp.SKColorType.Rgb565);
|
||||
|
||||
private static async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(dynamic pixelFormat)
|
||||
|
|
@ -150,7 +149,7 @@ namespace FFMpegCore.Test
|
|||
};
|
||||
|
||||
var videoFramesSource = new RawVideoPipeSource(frames);
|
||||
var ex = await Assert.ThrowsExceptionAsync<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
await Assert.ThrowsExactlyAsync<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
|
|
@ -158,11 +157,11 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentPixelFormats_WindowsOnly() =>
|
||||
Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(System.Drawing.Imaging.PixelFormat.Format24bppRgb, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentPixelFormats() => Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(SkiaSharp.SKColorType.Rgb565, SkiaSharp.SKColorType.Bgra8888);
|
||||
|
||||
private static void Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(dynamic pixelFormatFrame1, dynamic pixelFormatFrame2)
|
||||
|
|
@ -176,7 +175,7 @@ namespace FFMpegCore.Test
|
|||
};
|
||||
|
||||
var videoFramesSource = new RawVideoPipeSource(frames);
|
||||
var ex = Assert.ThrowsException<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
Assert.ThrowsExactly<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
|
|
@ -184,11 +183,11 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_WindowsOnly_Async() =>
|
||||
await Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(System.Drawing.Imaging.PixelFormat.Format24bppRgb, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_Async() => await Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(SkiaSharp.SKColorType.Rgb565, SkiaSharp.SKColorType.Bgra8888);
|
||||
|
||||
private static async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(dynamic pixelFormatFrame1, dynamic pixelFormatFrame2)
|
||||
|
|
@ -202,14 +201,14 @@ namespace FFMpegCore.Test
|
|||
};
|
||||
|
||||
var videoFramesSource = new RawVideoPipeSource(frames);
|
||||
var ex = await Assert.ThrowsExceptionAsync<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
await Assert.ThrowsExactlyAsync<FFMpegStreamFormatException>(() => FFMpegArguments
|
||||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.ProcessAsynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_StreamPipe()
|
||||
{
|
||||
using var input = File.OpenRead(TestResources.WebmVideo);
|
||||
|
|
@ -223,10 +222,10 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_StreamOutputPipe_Async_Failure()
|
||||
{
|
||||
await Assert.ThrowsExceptionAsync<FFMpegException>(async () =>
|
||||
await Assert.ThrowsExactlyAsync<FFMpegException>(async () =>
|
||||
{
|
||||
await using var ms = new MemoryStream();
|
||||
var pipeSource = new StreamPipeSink(ms);
|
||||
|
|
@ -237,7 +236,7 @@ namespace FFMpegCore.Test
|
|||
});
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_StreamFile_OutputToMemoryStream()
|
||||
{
|
||||
var output = new MemoryStream();
|
||||
|
|
@ -254,10 +253,10 @@ namespace FFMpegCore.Test
|
|||
Console.WriteLine(result.Duration);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_StreamOutputPipe_Failure()
|
||||
{
|
||||
Assert.ThrowsException<FFMpegException>(() =>
|
||||
Assert.ThrowsExactly<FFMpegException>(() =>
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
FFMpegArguments
|
||||
|
|
@ -268,7 +267,7 @@ namespace FFMpegCore.Test
|
|||
});
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_StreamOutputPipe_Async()
|
||||
{
|
||||
await using var ms = new MemoryStream();
|
||||
|
|
@ -281,7 +280,7 @@ namespace FFMpegCore.Test
|
|||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task TestDuplicateRun()
|
||||
{
|
||||
FFMpegArguments
|
||||
|
|
@ -297,7 +296,7 @@ namespace FFMpegCore.Test
|
|||
File.Delete("temporary.mp4");
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void TranscodeToMemoryStream_Success()
|
||||
{
|
||||
using var output = new MemoryStream();
|
||||
|
|
@ -315,7 +314,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(inputAnalysis.Duration.TotalSeconds, outputAnalysis.Duration.TotalSeconds, 0.3);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToTS()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.MpegTs.Extension}");
|
||||
|
|
@ -327,7 +326,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToTS_Args()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.MpegTs.Extension}");
|
||||
|
|
@ -343,12 +342,12 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyDataTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(System.Drawing.Imaging.PixelFormat.Format24bppRgb)]
|
||||
[DataRow(System.Drawing.Imaging.PixelFormat.Format32bppArgb)]
|
||||
public async Task Video_ToTS_Args_Pipe_WindowsOnly(System.Drawing.Imaging.PixelFormat pixelFormat) => await Video_ToTS_Args_Pipe_Internal(pixelFormat);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(SkiaSharp.SKColorType.Rgb565)]
|
||||
[DataRow(SkiaSharp.SKColorType.Bgra8888)]
|
||||
public async Task Video_ToTS_Args_Pipe(SkiaSharp.SKColorType pixelFormat) => await Video_ToTS_Args_Pipe_Internal(pixelFormat);
|
||||
|
|
@ -369,7 +368,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(VideoType.Ts.Name, analysis.Format.FormatName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToOGV_Resize()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Ogv.Extension}");
|
||||
|
|
@ -383,7 +382,7 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyDataTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(SkiaSharp.SKColorType.Rgb565)]
|
||||
[DataRow(SkiaSharp.SKColorType.Bgra8888)]
|
||||
public void RawVideoPipeSource_Ogv_Scale(SkiaSharp.SKColorType pixelFormat)
|
||||
|
|
@ -403,7 +402,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual((int)VideoSize.Ed, analysis.PrimaryVideoStream!.Width);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Scale_Mp4_Multithreaded()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -418,13 +417,13 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyDataTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(System.Drawing.Imaging.PixelFormat.Format24bppRgb)]
|
||||
[DataRow(System.Drawing.Imaging.PixelFormat.Format32bppArgb)]
|
||||
// [DataRow(PixelFormat.Format48bppRgb)]
|
||||
public void Video_ToMP4_Resize_Args_Pipe(System.Drawing.Imaging.PixelFormat pixelFormat) => Video_ToMP4_Resize_Args_Pipe_Internal(pixelFormat);
|
||||
|
||||
[DataTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[DataRow(SkiaSharp.SKColorType.Rgb565)]
|
||||
[DataRow(SkiaSharp.SKColorType.Bgra8888)]
|
||||
public void Video_ToMP4_Resize_Args_Pipe(SkiaSharp.SKColorType pixelFormat) => Video_ToMP4_Resize_Args_Pipe_Internal(pixelFormat);
|
||||
|
|
@ -443,7 +442,7 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_InMemory_SystemDrawingCommon()
|
||||
{
|
||||
using var bitmap = Extensions.System.Drawing.Common.FFMpegImage.Snapshot(TestResources.Mp4Video);
|
||||
|
|
@ -454,7 +453,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_InMemory_SkiaSharp()
|
||||
{
|
||||
using var bitmap = Extensions.SkiaSharp.FFMpegImage.Snapshot(TestResources.Mp4Video);
|
||||
|
|
@ -466,7 +465,7 @@ namespace FFMpegCore.Test
|
|||
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_Png_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.png");
|
||||
|
|
@ -480,7 +479,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_Jpg_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.jpg");
|
||||
|
|
@ -494,7 +493,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("mjpeg", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_Bmp_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.bmp");
|
||||
|
|
@ -508,7 +507,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("bmp", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_Webp_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.webp");
|
||||
|
|
@ -522,7 +521,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("webp", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_Exception_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.asd");
|
||||
|
|
@ -537,7 +536,7 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Snapshot_Rotated_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.png");
|
||||
|
|
@ -552,7 +551,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_GifSnapshot_PersistSnapshot()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.gif");
|
||||
|
|
@ -566,7 +565,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("gif", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_GifSnapshot_PersistSnapshot_SizeSupplied()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.gif");
|
||||
|
|
@ -581,7 +580,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("gif", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_GifSnapshot_PersistSnapshotAsync()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.gif");
|
||||
|
|
@ -595,7 +594,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("gif", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_GifSnapshot_PersistSnapshotAsync_SizeSupplied()
|
||||
{
|
||||
using var outputPath = new TemporaryFile("out.gif");
|
||||
|
|
@ -610,7 +609,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("gif", analysis.PrimaryVideoStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Join()
|
||||
{
|
||||
using var inputCopy = new TemporaryFile("copy-input.mp4");
|
||||
|
|
@ -632,7 +631,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(2 * BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(2 * BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Join_Image_Sequence()
|
||||
{
|
||||
var imageSet = new List<string>();
|
||||
|
|
@ -657,16 +656,16 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(imageAnalysis.PrimaryVideoStream!.Height, result.PrimaryVideoStream.Height);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_With_Only_Audio_Should_Extract_Metadata()
|
||||
{
|
||||
var video = FFProbe.Analyse(TestResources.Mp4WithoutVideo);
|
||||
Assert.AreEqual(null, video.PrimaryVideoStream);
|
||||
Assert.IsNull(video.PrimaryVideoStream);
|
||||
Assert.AreEqual("aac", video.PrimaryAudioStream!.CodecName);
|
||||
Assert.AreEqual(10, video.Duration.TotalSeconds, 0.5);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Duration()
|
||||
{
|
||||
var video = FFProbe.Analyse(TestResources.Mp4Video);
|
||||
|
|
@ -686,7 +685,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual(video.Duration.Seconds - 2, outputVideo.Duration.Seconds);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_UpdatesProgress()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -727,7 +726,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreNotEqual(analysis.Duration, timeDone);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_OutputsData()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -749,10 +748,10 @@ namespace FFMpegCore.Test
|
|||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[WindowsOnlyTestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_TranscodeInMemory_WindowsOnly() => Video_TranscodeInMemory_Internal(System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_TranscodeInMemory() => Video_TranscodeInMemory_Internal(SkiaSharp.SKColorType.Rgb565);
|
||||
|
||||
private static void Video_TranscodeInMemory_Internal(dynamic pixelFormat)
|
||||
|
|
@ -770,11 +769,11 @@ namespace FFMpegCore.Test
|
|||
|
||||
resStream.Position = 0;
|
||||
var vi = FFProbe.Analyse(resStream);
|
||||
Assert.AreEqual(vi.PrimaryVideoStream!.Width, 128);
|
||||
Assert.AreEqual(vi.PrimaryVideoStream.Height, 128);
|
||||
Assert.AreEqual(128, vi.PrimaryVideoStream!.Width);
|
||||
Assert.AreEqual(128, vi.PrimaryVideoStream.Height);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(2 * BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(2 * BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_TranscodeToMemory()
|
||||
{
|
||||
using var memoryStream = new MemoryStream();
|
||||
|
|
@ -788,11 +787,11 @@ namespace FFMpegCore.Test
|
|||
|
||||
memoryStream.Position = 0;
|
||||
var vi = FFProbe.Analyse(memoryStream);
|
||||
Assert.AreEqual(vi.PrimaryVideoStream!.Width, 640);
|
||||
Assert.AreEqual(vi.PrimaryVideoStream.Height, 360);
|
||||
Assert.AreEqual(640, vi.PrimaryVideoStream!.Width);
|
||||
Assert.AreEqual(360, vi.PrimaryVideoStream.Height);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_Cancel_Async()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -816,7 +815,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Cancel()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -837,7 +836,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_Cancel_Async_With_Timeout()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -867,7 +866,7 @@ namespace FFMpegCore.Test
|
|||
Assert.AreEqual("aac", outputInfo.PrimaryAudioStream!.CodecName);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_Cancel_CancellationToken_Async()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -892,7 +891,7 @@ namespace FFMpegCore.Test
|
|||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_Cancel_CancellationToken_Async_Throws()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -912,10 +911,10 @@ namespace FFMpegCore.Test
|
|||
|
||||
cts.CancelAfter(300);
|
||||
|
||||
await Assert.ThrowsExceptionAsync<OperationCanceledException>(() => task);
|
||||
await Assert.ThrowsExactlyAsync<OperationCanceledException>(() => task);
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Cancel_CancellationToken_Throws()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
@ -934,10 +933,10 @@ namespace FFMpegCore.Test
|
|||
|
||||
cts.CancelAfter(300);
|
||||
|
||||
Assert.ThrowsException<OperationCanceledException>(() => task.ProcessSynchronously());
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds)]
|
||||
[TestMethod, Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_Cancel_CancellationToken_Async_With_Timeout()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue