mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-16 11:05:44 +00:00
Compare commits
No commits in common. "a599c48511cb9ba059b00e3c3a4276650388ec4b" and "0d07456c6e158122fbf82c9e75255a4688b89ee9" have entirely different histories.
a599c48511
...
0d07456c6e
7 changed files with 69 additions and 131 deletions
|
|
@ -9,10 +9,6 @@ namespace FFMpegCore.Test;
|
|||
[TestClass]
|
||||
public class AudioTest
|
||||
{
|
||||
private const int BaseTimeoutMilliseconds = 30_000;
|
||||
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
[TestMethod]
|
||||
public void Audio_Remove()
|
||||
{
|
||||
|
|
@ -45,7 +41,6 @@ public class AudioTest
|
|||
await FFMpegArguments
|
||||
.FromPipeInput(new StreamPipeSource(file), options => options.ForceFormat("s16le"))
|
||||
.OutputToPipe(new StreamPipeSink(memoryStream), options => options.ForceFormat("mp3"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +70,7 @@ public class AudioTest
|
|||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -88,13 +83,12 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToLibVorbis_Args_Pipe()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -107,13 +101,12 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.LibVorbis))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Audio_ToAAC_Args_Pipe_Async()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -126,13 +119,12 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_ValidDefaultConfiguration()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -145,13 +137,12 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_InvalidChannels()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -162,12 +153,11 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_InvalidFormat()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -178,12 +168,11 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_ToAAC_Args_Pipe_InvalidSampleRate()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -194,12 +183,11 @@ public class AudioTest
|
|||
.FromPipeInput(audioSamplesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMono()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -208,7 +196,6 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.Pan(1, "c0 < 0.9 * c0 + 0.1 * c1")))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
var mediaAnalysis = FFProbe.Analyse(outputFile);
|
||||
|
|
@ -219,7 +206,7 @@ public class AudioTest
|
|||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMonoNoDefinitions()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -228,7 +215,6 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.Pan(1)))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
var mediaAnalysis = FFProbe.Analyse(outputFile);
|
||||
|
|
@ -239,7 +225,7 @@ public class AudioTest
|
|||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMonoChannelsToOutputDefinitionsMismatch()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -248,12 +234,11 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.Pan(1, "c0=c0", "c1=c1")))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_Pan_ToMonoChannelsLayoutToOutputDefinitionsMismatch()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -262,12 +247,11 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.Pan("mono", "c0=c0", "c1=c1")))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_DynamicNormalizer_WithDefaultValues()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -276,14 +260,13 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.DynamicNormalizer()))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public void Audio_DynamicNormalizer_WithNonDefaultValues()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
|
@ -292,14 +275,13 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.DynamicNormalizer(250, 7, 0.9, 2, 1, false, true, true, 0.5)))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
[DataRow(2)]
|
||||
[DataRow(32)]
|
||||
[DataRow(8)]
|
||||
|
|
@ -312,7 +294,6 @@ public class AudioTest
|
|||
.OutputToFile(outputFile, true,
|
||||
argumentOptions => argumentOptions
|
||||
.WithAudioFilters(filter => filter.DynamicNormalizer(filterWindow: filterWindow)))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace FFMpegCore.Test;
|
|||
[TestClass]
|
||||
public class VideoTest
|
||||
{
|
||||
private const int BaseTimeoutMilliseconds = 60_000;
|
||||
private const int BaseTimeoutMilliseconds = 15_000;
|
||||
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
|
|
@ -30,7 +30,6 @@ public class VideoTest
|
|||
var success = FFMpegArguments
|
||||
.FromFileInput(TestResources.WebmVideo)
|
||||
.OutputToFile(outputFile, false)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -44,7 +43,6 @@ public class VideoTest
|
|||
var success = FFMpegArguments
|
||||
.FromFileInput(TestResources.WebmVideo)
|
||||
.OutputToFile(outputFile, false)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -60,7 +58,6 @@ public class VideoTest
|
|||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.ForcePixelFormat("yuv444p"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
var analysis = FFProbe.Analyse(outputFile);
|
||||
|
|
@ -77,7 +74,6 @@ public class VideoTest
|
|||
.FromFileInput(TestResources.WebmVideo)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -92,7 +88,6 @@ public class VideoTest
|
|||
.FromFileInput(TestResources.WebmVideo)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX265))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -104,7 +99,7 @@ public class VideoTest
|
|||
[DataRow(PixelFormat.Format32bppArgb)]
|
||||
public void Video_ToMP4_Args_Pipe_WindowsOnly(PixelFormat pixelFormat)
|
||||
{
|
||||
Video_ToMP4_Args_Pipe_Internal(pixelFormat, TestContext.CancellationToken);
|
||||
Video_ToMP4_Args_Pipe_Internal(pixelFormat);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -113,10 +108,10 @@ public class VideoTest
|
|||
[DataRow(SKColorType.Bgra8888)]
|
||||
public void Video_ToMP4_Args_Pipe(SKColorType pixelFormat)
|
||||
{
|
||||
Video_ToMP4_Args_Pipe_Internal(pixelFormat, TestContext.CancellationToken);
|
||||
Video_ToMP4_Args_Pipe_Internal(pixelFormat);
|
||||
}
|
||||
|
||||
private static void Video_ToMP4_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||
private static void Video_ToMP4_Args_Pipe_Internal(dynamic pixelFormat)
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
|
|
@ -125,7 +120,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -135,17 +129,17 @@ public class VideoTest
|
|||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentImageSizes_WindowsOnly()
|
||||
{
|
||||
Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(PixelFormat.Format24bppRgb, TestContext.CancellationToken);
|
||||
Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(PixelFormat.Format24bppRgb);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentImageSizes()
|
||||
{
|
||||
Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(SKColorType.Rgb565, TestContext.CancellationToken);
|
||||
Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(SKColorType.Rgb565);
|
||||
}
|
||||
|
||||
private static void Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||
private static void Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal(dynamic pixelFormat)
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
|
|
@ -159,7 +153,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -168,17 +161,17 @@ public class VideoTest
|
|||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_WindowsOnly_Async()
|
||||
{
|
||||
await Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(PixelFormat.Format24bppRgb, TestContext.CancellationToken);
|
||||
await Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(PixelFormat.Format24bppRgb);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_Async()
|
||||
{
|
||||
await Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(SKColorType.Rgb565, TestContext.CancellationToken);
|
||||
await Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(SKColorType.Rgb565);
|
||||
}
|
||||
|
||||
private static async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||
private static async Task Video_ToMP4_Args_Pipe_DifferentImageSizes_Internal_Async(dynamic pixelFormat)
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
|
|
@ -192,7 +185,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -202,18 +194,17 @@ public class VideoTest
|
|||
public void Video_ToMP4_Args_Pipe_DifferentPixelFormats_WindowsOnly()
|
||||
{
|
||||
Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(PixelFormat.Format24bppRgb,
|
||||
PixelFormat.Format32bppRgb, TestContext.CancellationToken);
|
||||
PixelFormat.Format32bppRgb);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToMP4_Args_Pipe_DifferentPixelFormats()
|
||||
{
|
||||
Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(SKColorType.Rgb565, SKColorType.Bgra8888, TestContext.CancellationToken);
|
||||
Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(SKColorType.Rgb565, SKColorType.Bgra8888);
|
||||
}
|
||||
|
||||
private static void Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(dynamic pixelFormatFrame1, dynamic pixelFormatFrame2,
|
||||
CancellationToken cancellationToken)
|
||||
private static void Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal(dynamic pixelFormatFrame1, dynamic pixelFormatFrame2)
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
|
|
@ -227,7 +218,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -237,18 +227,17 @@ public class VideoTest
|
|||
public async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_WindowsOnly_Async()
|
||||
{
|
||||
await Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(PixelFormat.Format24bppRgb,
|
||||
PixelFormat.Format32bppRgb, TestContext.CancellationToken);
|
||||
PixelFormat.Format32bppRgb);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_Async()
|
||||
{
|
||||
await Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(SKColorType.Rgb565, SKColorType.Bgra8888, TestContext.CancellationToken);
|
||||
await Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(SKColorType.Rgb565, SKColorType.Bgra8888);
|
||||
}
|
||||
|
||||
private static async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(dynamic pixelFormatFrame1, dynamic pixelFormatFrame2,
|
||||
CancellationToken cancellationToken)
|
||||
private static async Task Video_ToMP4_Args_Pipe_DifferentPixelFormats_Internal_Async(dynamic pixelFormatFrame1, dynamic pixelFormatFrame2)
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
|
|
@ -262,7 +251,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +265,6 @@ public class VideoTest
|
|||
.FromPipeInput(new StreamPipeSource(input))
|
||||
.OutputToFile(output, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -293,7 +280,6 @@ public class VideoTest
|
|||
await FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToPipe(pipeSource, opt => opt.ForceFormat("mp4"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
});
|
||||
}
|
||||
|
|
@ -309,7 +295,6 @@ public class VideoTest
|
|||
.ForceFormat("webm"))
|
||||
.OutputToPipe(new StreamPipeSink(output), opt => opt
|
||||
.ForceFormat("mpegts"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
output.Position = 0;
|
||||
|
|
@ -328,7 +313,6 @@ public class VideoTest
|
|||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToPipe(new StreamPipeSink(ms), opt => opt
|
||||
.ForceFormat("mkv"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
});
|
||||
}
|
||||
|
|
@ -344,7 +328,6 @@ public class VideoTest
|
|||
.OutputToPipe(pipeSource, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.ForceFormat("matroska"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
|
|
@ -355,13 +338,11 @@ public class VideoTest
|
|||
FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToFile("temporary.mp4")
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
await FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToFile("temporary.mp4")
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
|
||||
File.Delete("temporary.mp4");
|
||||
|
|
@ -377,7 +358,6 @@ public class VideoTest
|
|||
.OutputToPipe(new StreamPipeSink(output), opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibVpx)
|
||||
.ForceFormat("matroska"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
|
||||
|
|
@ -396,7 +376,6 @@ public class VideoTest
|
|||
var success = FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToFile(outputFile, false)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -413,7 +392,6 @@ public class VideoTest
|
|||
.CopyChannel()
|
||||
.WithBitStreamFilter(Channel.Video, Filter.H264_Mp4ToAnnexB)
|
||||
.ForceFormat(VideoType.MpegTs))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -425,7 +403,7 @@ public class VideoTest
|
|||
[DataRow(PixelFormat.Format32bppArgb)]
|
||||
public async Task Video_ToTS_Args_Pipe_WindowsOnly(PixelFormat pixelFormat)
|
||||
{
|
||||
await Video_ToTS_Args_Pipe_Internal(pixelFormat, TestContext.CancellationToken);
|
||||
await Video_ToTS_Args_Pipe_Internal(pixelFormat);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -434,10 +412,10 @@ public class VideoTest
|
|||
[DataRow(SKColorType.Bgra8888)]
|
||||
public async Task Video_ToTS_Args_Pipe(SKColorType pixelFormat)
|
||||
{
|
||||
await Video_ToTS_Args_Pipe_Internal(pixelFormat, TestContext.CancellationToken);
|
||||
await Video_ToTS_Args_Pipe_Internal(pixelFormat);
|
||||
}
|
||||
|
||||
private static async Task Video_ToTS_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||
private static async Task Video_ToTS_Args_Pipe_Internal(dynamic pixelFormat)
|
||||
{
|
||||
using var output = new TemporaryFile($"out{VideoType.Ts.Extension}");
|
||||
var input = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 256, 256));
|
||||
|
|
@ -446,7 +424,6 @@ public class VideoTest
|
|||
.FromPipeInput(input)
|
||||
.OutputToFile(output, false, opt => opt
|
||||
.ForceFormat(VideoType.Ts))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
Assert.IsTrue(success);
|
||||
|
||||
|
|
@ -464,7 +441,6 @@ public class VideoTest
|
|||
.OutputToFile(outputFile, false, opt => opt
|
||||
.Resize(200, 200)
|
||||
.WithVideoCodec(VideoCodec.LibTheora))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -485,7 +461,6 @@ public class VideoTest
|
|||
.WithVideoFilters(filterOptions => filterOptions
|
||||
.Scale(VideoSize.Ed))
|
||||
.WithVideoCodec(VideoCodec.LibTheora))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
var analysis = FFProbe.Analyse(outputFile);
|
||||
|
|
@ -503,7 +478,6 @@ public class VideoTest
|
|||
.OutputToFile(outputFile, false, opt => opt
|
||||
.UsingMultithreading(true)
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -516,7 +490,7 @@ public class VideoTest
|
|||
// [DataRow(PixelFormat.Format48bppRgb)]
|
||||
public void Video_ToMP4_Resize_Args_Pipe(PixelFormat pixelFormat)
|
||||
{
|
||||
Video_ToMP4_Resize_Args_Pipe_Internal(pixelFormat, TestContext.CancellationToken);
|
||||
Video_ToMP4_Resize_Args_Pipe_Internal(pixelFormat);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -525,10 +499,10 @@ public class VideoTest
|
|||
[DataRow(SKColorType.Bgra8888)]
|
||||
public void Video_ToMP4_Resize_Args_Pipe(SKColorType pixelFormat)
|
||||
{
|
||||
Video_ToMP4_Resize_Args_Pipe_Internal(pixelFormat, TestContext.CancellationToken);
|
||||
Video_ToMP4_Resize_Args_Pipe_Internal(pixelFormat);
|
||||
}
|
||||
|
||||
private static void Video_ToMP4_Resize_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||
private static void Video_ToMP4_Resize_Args_Pipe_Internal(dynamic pixelFormat)
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 256, 256));
|
||||
|
|
@ -537,7 +511,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -766,7 +739,7 @@ public class VideoTest
|
|||
Assert.IsTrue(success);
|
||||
var result = FFProbe.Analyse(outputFile);
|
||||
|
||||
Assert.AreEqual(3, result.Duration.Seconds);
|
||||
Assert.AreEqual(1, result.Duration.Seconds);
|
||||
Assert.AreEqual(imageAnalysis.PrimaryVideoStream!.Width, result.PrimaryVideoStream!.Width);
|
||||
Assert.AreEqual(imageAnalysis.PrimaryVideoStream!.Height, result.PrimaryVideoStream.Height);
|
||||
}
|
||||
|
|
@ -791,7 +764,6 @@ public class VideoTest
|
|||
FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToFile(outputFile, false, opt => opt.WithDuration(TimeSpan.FromSeconds(video.Duration.TotalSeconds - 2)))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
Assert.IsTrue(File.Exists(outputFile));
|
||||
|
|
@ -813,12 +785,12 @@ public class VideoTest
|
|||
var timeDone = TimeSpan.Zero;
|
||||
var analysis = FFProbe.Analyse(TestResources.Mp4Video);
|
||||
|
||||
var events = new List<double>();
|
||||
|
||||
void OnPercentageProgess(double percentage)
|
||||
{
|
||||
events.Add(percentage);
|
||||
percentageDone = percentage;
|
||||
if (percentage < 100)
|
||||
{
|
||||
percentageDone = percentage;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTimeProgess(TimeSpan time)
|
||||
|
|
@ -835,16 +807,12 @@ public class VideoTest
|
|||
.WithDuration(analysis.Duration))
|
||||
.NotifyOnProgress(OnPercentageProgess, analysis.Duration)
|
||||
.NotifyOnProgress(OnTimeProgess)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
Assert.IsTrue(success);
|
||||
Assert.IsTrue(File.Exists(outputFile));
|
||||
Assert.AreNotEqual(0.0, percentageDone);
|
||||
Assert.IsGreaterThan(1, events.Count);
|
||||
CollectionAssert.AllItemsAreUnique(events);
|
||||
Assert.AreNotEqual(100.0, events.First());
|
||||
Assert.AreEqual(100.0, events.Last(), 0.001);
|
||||
Assert.AreNotEqual(100.0, percentageDone);
|
||||
Assert.AreNotEqual(TimeSpan.Zero, timeDone);
|
||||
Assert.AreNotEqual(analysis.Duration, timeDone);
|
||||
}
|
||||
|
|
@ -864,7 +832,6 @@ public class VideoTest
|
|||
.WithDuration(TimeSpan.FromSeconds(2)))
|
||||
.NotifyOnError(_ => dataReceived = true)
|
||||
.Configure(opt => opt.Encoding = Encoding.UTF8)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
Assert.IsTrue(dataReceived);
|
||||
|
|
@ -877,17 +844,17 @@ public class VideoTest
|
|||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_TranscodeInMemory_WindowsOnly()
|
||||
{
|
||||
Video_TranscodeInMemory_Internal(PixelFormat.Format24bppRgb, TestContext.CancellationToken);
|
||||
Video_TranscodeInMemory_Internal(PixelFormat.Format24bppRgb);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_TranscodeInMemory()
|
||||
{
|
||||
Video_TranscodeInMemory_Internal(SKColorType.Rgb565, TestContext.CancellationToken);
|
||||
Video_TranscodeInMemory_Internal(SKColorType.Rgb565);
|
||||
}
|
||||
|
||||
private static void Video_TranscodeInMemory_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||
private static void Video_TranscodeInMemory_Internal(dynamic pixelFormat)
|
||||
{
|
||||
using var resStream = new MemoryStream();
|
||||
var reader = new StreamPipeSink(resStream);
|
||||
|
|
@ -898,7 +865,6 @@ public class VideoTest
|
|||
.OutputToPipe(reader, opt => opt
|
||||
.WithVideoCodec("vp9")
|
||||
.ForceFormat("webm"))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
resStream.Position = 0;
|
||||
|
|
@ -918,7 +884,6 @@ public class VideoTest
|
|||
.OutputToPipe(new StreamPipeSink(memoryStream), opt => opt
|
||||
.WithVideoCodec("vp9")
|
||||
.ForceFormat("webm"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
memoryStream.Position = 0;
|
||||
|
|
@ -942,8 +907,6 @@ public class VideoTest
|
|||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(out var cancel)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously(false);
|
||||
|
||||
await Task.Delay(300, TestContext.CancellationToken);
|
||||
|
|
@ -967,13 +930,11 @@ public class VideoTest
|
|||
.WithAudioCodec(AudioCodec.Aac)
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(out var cancel)
|
||||
.CancellableThrough(TestContext.CancellationToken);
|
||||
.CancellableThrough(out var cancel);
|
||||
|
||||
Task.Delay(300, TestContext.CancellationToken).ContinueWith(_ => cancel(), TestContext.CancellationToken);
|
||||
|
||||
var result = task.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously(false);
|
||||
var result = task.ProcessSynchronously(false);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
|
@ -993,7 +954,6 @@ public class VideoTest
|
|||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(out var cancel, 10000)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously(false);
|
||||
|
||||
await Task.Delay(300, TestContext.CancellationToken);
|
||||
|
|
@ -1027,7 +987,6 @@ public class VideoTest
|
|||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(cts.Token)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously(false);
|
||||
|
||||
cts.CancelAfter(300);
|
||||
|
|
@ -1054,7 +1013,6 @@ public class VideoTest
|
|||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(cts.Token)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
|
||||
cts.CancelAfter(300);
|
||||
|
|
@ -1082,8 +1040,7 @@ public class VideoTest
|
|||
|
||||
cts.CancelAfter(300);
|
||||
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -1105,8 +1062,7 @@ public class VideoTest
|
|||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(cts.Token);
|
||||
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ namespace FFMpegCore.Arguments;
|
|||
|
||||
public class GifPaletteArgument : IArgument
|
||||
{
|
||||
private readonly double _fps;
|
||||
private readonly int _fps;
|
||||
|
||||
private readonly Size? _size;
|
||||
private readonly int _streamIndex;
|
||||
|
||||
public GifPaletteArgument(int streamIndex, double fps, Size? size)
|
||||
public GifPaletteArgument(int streamIndex, int fps, Size? size)
|
||||
{
|
||||
_streamIndex = streamIndex;
|
||||
_fps = fps;
|
||||
|
|
|
|||
|
|
@ -132,8 +132,7 @@ public static class FFMpeg
|
|||
}
|
||||
|
||||
return FFMpegArguments
|
||||
.FromFileInput(Path.Combine(tempFolderName, $"%09d{fileExtension}"), false, options => options
|
||||
.WithFramerate(frameRate))
|
||||
.FromFileInput(Path.Combine(tempFolderName, $"%09d{fileExtension}"), false)
|
||||
.OutputToFile(output, true, options => options
|
||||
.ForcePixelFormat("yuv420p")
|
||||
.Resize(width!.Value, height!.Value)
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ public class FFMpegArgumentOptions : FFMpegArgumentsBase
|
|||
return WithArgument(new ID3V2VersionArgument(id3v2Version));
|
||||
}
|
||||
|
||||
public FFMpegArgumentOptions WithGifPaletteArgument(int streamIndex, Size? size, double fps = 12)
|
||||
public FFMpegArgumentOptions WithGifPaletteArgument(int streamIndex, Size? size, int fps = 12)
|
||||
{
|
||||
return WithArgument(new GifPaletteArgument(streamIndex, fps, size));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace FFMpegCore;
|
|||
public class FFMpegArgumentProcessor
|
||||
{
|
||||
private static readonly Regex ProgressRegex = new(@"time=(\d\d:\d\d:\d\d.\d\d?)", RegexOptions.Compiled);
|
||||
private readonly CancellationTokenSource _cancellationTokenSource = new();
|
||||
private readonly List<Action<FFOptions>> _configurations;
|
||||
private readonly FFMpegArguments _ffMpegArguments;
|
||||
private CancellationTokenRegistration? _cancellationTokenRegistration;
|
||||
|
|
@ -31,6 +32,12 @@ public class FFMpegArgumentProcessor
|
|||
|
||||
private event EventHandler<int> CancelEvent = null!;
|
||||
|
||||
~FFMpegArgumentProcessor()
|
||||
{
|
||||
_cancellationTokenSource.Dispose();
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register action that will be invoked during the ffmpeg processing, when a progress time is output and parsed and progress percentage is
|
||||
/// calculated.
|
||||
|
|
@ -85,7 +92,6 @@ public class FFMpegArgumentProcessor
|
|||
|
||||
public FFMpegArgumentProcessor CancellableThrough(CancellationToken token, int timeout = 0)
|
||||
{
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
_cancellationTokenRegistration = token.Register(() => Cancel(timeout));
|
||||
return this;
|
||||
}
|
||||
|
|
@ -111,12 +117,11 @@ public class FFMpegArgumentProcessor
|
|||
{
|
||||
var options = GetConfiguredOptions(ffMpegOptions);
|
||||
var processArguments = PrepareProcessArguments(options);
|
||||
using var cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
IProcessResult? processResult = null;
|
||||
try
|
||||
{
|
||||
processResult = Process(processArguments, cancellationTokenSource).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
processResult = Process(processArguments).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
@ -133,12 +138,11 @@ public class FFMpegArgumentProcessor
|
|||
{
|
||||
var options = GetConfiguredOptions(ffMpegOptions);
|
||||
var processArguments = PrepareProcessArguments(options);
|
||||
using var cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
IProcessResult? processResult = null;
|
||||
try
|
||||
{
|
||||
processResult = await Process(processArguments, cancellationTokenSource).ConfigureAwait(false);
|
||||
processResult = await Process(processArguments).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
@ -151,12 +155,11 @@ public class FFMpegArgumentProcessor
|
|||
return HandleCompletion(throwOnError, processResult?.ExitCode ?? -1, processResult?.ErrorData ?? Array.Empty<string>());
|
||||
}
|
||||
|
||||
private async Task<IProcessResult> Process(ProcessArguments processArguments, CancellationTokenSource cancellationTokenSource)
|
||||
private async Task<IProcessResult> Process(ProcessArguments processArguments)
|
||||
{
|
||||
IProcessResult processResult = null!;
|
||||
if (_cancelled)
|
||||
{
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
throw new OperationCanceledException("cancelled before starting processing");
|
||||
}
|
||||
|
||||
|
|
@ -168,9 +171,9 @@ public class FFMpegArgumentProcessor
|
|||
{
|
||||
instance.SendInput("q");
|
||||
|
||||
if (!cancellationTokenSource.Token.WaitHandle.WaitOne(timeout, true))
|
||||
if (!_cancellationTokenSource.Token.WaitHandle.WaitOne(timeout, true))
|
||||
{
|
||||
cancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource.Cancel();
|
||||
instance.Kill();
|
||||
}
|
||||
}
|
||||
|
|
@ -182,13 +185,12 @@ public class FFMpegArgumentProcessor
|
|||
await Task.WhenAll(instance.WaitForExitAsync().ContinueWith(t =>
|
||||
{
|
||||
processResult = t.Result;
|
||||
cancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource.Cancel();
|
||||
_ffMpegArguments.Post();
|
||||
}), _ffMpegArguments.During(cancellationTokenSource.Token)).ConfigureAwait(false);
|
||||
}), _ffMpegArguments.During(_cancellationTokenSource.Token)).ConfigureAwait(false);
|
||||
|
||||
if (_cancelled)
|
||||
{
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
throw new OperationCanceledException("ffmpeg processing was cancelled");
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +199,6 @@ public class FFMpegArgumentProcessor
|
|||
finally
|
||||
{
|
||||
CancelEvent -= OnCancelEvent;
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public static class SnapshotArgumentBuilder
|
|||
TimeSpan? captureTime = null,
|
||||
TimeSpan? duration = null,
|
||||
int? streamIndex = null,
|
||||
double fps = 12)
|
||||
int fps = 12)
|
||||
{
|
||||
var defaultGifOutputSize = new Size(480, -1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue