mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-16 11:05:44 +00:00
Compare commits
No commits in common. "ed8f899d04a1f71c481e02b2123176d5cd097a4a" and "46512524279735e94254f32f844e8a32f0ddf87b" have entirely different histories.
ed8f899d04
...
4651252427
16 changed files with 94 additions and 396 deletions
|
|
@ -39,21 +39,18 @@ public static class FFMpegImage
|
|||
/// <param name="size">Thumbnail size. If width or height equal 0, the other will be computed automatically.</param>
|
||||
/// <param name="streamIndex">Selected video stream index.</param>
|
||||
/// <param name="inputFileIndex">Input file index</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Bitmap with the requested snapshot.</returns>
|
||||
public static async Task<SKBitmap> SnapshotAsync(string input, Size? size = null, TimeSpan? captureTime = null, int? streamIndex = null,
|
||||
int inputFileIndex = 0, CancellationToken cancellationToken = default)
|
||||
int inputFileIndex = 0)
|
||||
{
|
||||
var source = await FFProbe.AnalyseAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
var source = await FFProbe.AnalyseAsync(input).ConfigureAwait(false);
|
||||
var (arguments, outputOptions) = SnapshotArgumentBuilder.BuildSnapshotArguments(input, source, size, captureTime, streamIndex, inputFileIndex);
|
||||
using var ms = new MemoryStream();
|
||||
|
||||
await arguments
|
||||
.OutputToPipe(new StreamPipeSink(ms), options => outputOptions(options
|
||||
.ForceFormat("rawvideo")))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously()
|
||||
.ConfigureAwait(false);
|
||||
.ProcessAsynchronously();
|
||||
|
||||
ms.Position = 0;
|
||||
return SKBitmap.Decode(ms);
|
||||
|
|
|
|||
|
|
@ -38,21 +38,18 @@ public static class FFMpegImage
|
|||
/// <param name="size">Thumbnail size. If width or height equal 0, the other will be computed automatically.</param>
|
||||
/// <param name="streamIndex">Selected video stream index.</param>
|
||||
/// <param name="inputFileIndex">Input file index</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Bitmap with the requested snapshot.</returns>
|
||||
public static async Task<Bitmap> SnapshotAsync(string input, Size? size = null, TimeSpan? captureTime = null, int? streamIndex = null,
|
||||
int inputFileIndex = 0, CancellationToken cancellationToken = default)
|
||||
int inputFileIndex = 0)
|
||||
{
|
||||
var source = await FFProbe.AnalyseAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
var source = await FFProbe.AnalyseAsync(input).ConfigureAwait(false);
|
||||
var (arguments, outputOptions) = SnapshotArgumentBuilder.BuildSnapshotArguments(input, source, size, captureTime, streamIndex, inputFileIndex);
|
||||
using var ms = new MemoryStream();
|
||||
|
||||
await arguments
|
||||
.OutputToPipe(new StreamPipeSink(ms), options => outputOptions(options
|
||||
.ForceFormat("rawvideo")))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously()
|
||||
.ConfigureAwait(false);
|
||||
.ProcessAsynchronously();
|
||||
|
||||
ms.Position = 0;
|
||||
return new Bitmap(ms);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
using FFMpegCore.Exceptions;
|
||||
using FFMpegCore.Helpers;
|
||||
using FFMpegCore.Test.Resources;
|
||||
using FFMpegCore.Test.Resources;
|
||||
|
||||
namespace FFMpegCore.Test;
|
||||
|
||||
|
|
@ -287,68 +285,4 @@ public class FFProbeTests
|
|||
var info = FFProbe.Analyse(TestResources.Mp4Video, customArguments: "-headers \"Hello: World\"");
|
||||
Assert.AreEqual(3, info.Duration.Seconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task Parallel_FFProbe_Cancellation_Should_Throw_Only_OperationCanceledException()
|
||||
{
|
||||
// Warm up FFMpegCore environment
|
||||
FFProbeHelper.VerifyFFProbeExists(GlobalFFOptions.Current);
|
||||
|
||||
var mp4 = TestResources.Mp4Video;
|
||||
if (!File.Exists(mp4))
|
||||
{
|
||||
Assert.Inconclusive($"Test video not found: {mp4}");
|
||||
return;
|
||||
}
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
using var semaphore = new SemaphoreSlim(Environment.ProcessorCount, Environment.ProcessorCount);
|
||||
var tasks = Enumerable.Range(0, 50).Select(x => Task.Run(async () =>
|
||||
{
|
||||
await semaphore.WaitAsync(cts.Token);
|
||||
try
|
||||
{
|
||||
var analysis = await FFProbe.AnalyseAsync(mp4, cancellationToken: cts.Token);
|
||||
return analysis;
|
||||
}
|
||||
finally
|
||||
{
|
||||
semaphore.Release();
|
||||
}
|
||||
}, cts.Token)).ToList();
|
||||
|
||||
// Wait for 2 tasks to finish, then cancel all
|
||||
await Task.WhenAny(tasks);
|
||||
await Task.WhenAny(tasks);
|
||||
await cts.CancelAsync();
|
||||
|
||||
var exceptions = new List<Exception>();
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
try
|
||||
{
|
||||
await task;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
exceptions.Add(e);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsNotEmpty(exceptions, "No exceptions were thrown on cancellation. Test was useless. " +
|
||||
".Try adjust cancellation timings to make cancellation at the moment, when ffprobe is still running.");
|
||||
|
||||
// Check that all exceptions are OperationCanceledException
|
||||
CollectionAssert.AllItemsAreInstancesOfType(exceptions, typeof(OperationCanceledException));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(10000, CooperativeCancellation = true)]
|
||||
public async Task FFProbe_Should_Throw_FFMpegException_When_Exits_With_Non_Zero_Code()
|
||||
{
|
||||
var input = TestResources.SrtSubtitle; //non media file
|
||||
await Assert.ThrowsAsync<FFMpegException>(async () => await FFProbe.AnalyseAsync(input,
|
||||
cancellationToken: TestContext.CancellationToken, customArguments: "--some-invalid-argument"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,45 +74,10 @@ public class VideoTest
|
|||
.FromFileInput(TestResources.WebmVideo)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public async Task Video_MetadataBuilder()
|
||||
{
|
||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||
|
||||
await FFMpegArguments
|
||||
.FromFileInput(TestResources.WebmVideo)
|
||||
.AddMetaData(FFMetadataBuilder.Empty()
|
||||
.WithTag("title", "noname")
|
||||
.WithTag("artist", "unknown")
|
||||
.WithChapter("Chapter 1", 1.1)
|
||||
.WithChapter("Chapter 2", 1.23))
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
|
||||
var analysis = await FFProbe.AnalyseAsync(outputFile, cancellationToken: TestContext.CancellationToken);
|
||||
Assert.IsTrue(analysis.Format.Tags!.TryGetValue("title", out var title));
|
||||
Assert.IsTrue(analysis.Format.Tags!.TryGetValue("artist", out var artist));
|
||||
Assert.AreEqual("noname", title);
|
||||
Assert.AreEqual("unknown", artist);
|
||||
|
||||
Assert.HasCount(2, analysis.Chapters);
|
||||
Assert.AreEqual("Chapter 1", analysis.Chapters.First().Title);
|
||||
Assert.AreEqual(1.1, analysis.Chapters.First().Duration.TotalSeconds);
|
||||
Assert.AreEqual(1.1, analysis.Chapters.First().End.TotalSeconds);
|
||||
|
||||
Assert.AreEqual("Chapter 2", analysis.Chapters.Last().Title);
|
||||
Assert.AreEqual(1.23, analysis.Chapters.Last().Duration.TotalSeconds);
|
||||
Assert.AreEqual(1.1 + 1.23, analysis.Chapters.Last().End.TotalSeconds);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_ToH265_MKV_Args()
|
||||
|
|
@ -126,7 +88,6 @@ public class VideoTest
|
|||
.FromFileInput(TestResources.WebmVideo)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX265))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -138,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]
|
||||
|
|
@ -147,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}");
|
||||
|
||||
|
|
@ -159,7 +120,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -169,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}");
|
||||
|
||||
|
|
@ -193,7 +153,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -202,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}");
|
||||
|
||||
|
|
@ -226,7 +185,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -236,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}");
|
||||
|
||||
|
|
@ -261,7 +218,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -271,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}");
|
||||
|
||||
|
|
@ -296,7 +251,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously());
|
||||
}
|
||||
|
||||
|
|
@ -311,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);
|
||||
}
|
||||
|
|
@ -327,7 +280,6 @@ public class VideoTest
|
|||
await FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToPipe(pipeSource, opt => opt.ForceFormat("mp4"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
});
|
||||
}
|
||||
|
|
@ -343,7 +295,6 @@ public class VideoTest
|
|||
.ForceFormat("webm"))
|
||||
.OutputToPipe(new StreamPipeSink(output), opt => opt
|
||||
.ForceFormat("mpegts"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
output.Position = 0;
|
||||
|
|
@ -362,7 +313,6 @@ public class VideoTest
|
|||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToPipe(new StreamPipeSink(ms), opt => opt
|
||||
.ForceFormat("mkv"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
});
|
||||
}
|
||||
|
|
@ -378,7 +328,6 @@ public class VideoTest
|
|||
.OutputToPipe(pipeSource, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.ForceFormat("matroska"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
|
|
@ -389,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");
|
||||
|
|
@ -411,7 +358,6 @@ public class VideoTest
|
|||
.OutputToPipe(new StreamPipeSink(output), opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibVpx)
|
||||
.ForceFormat("matroska"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
|
||||
|
|
@ -430,7 +376,6 @@ public class VideoTest
|
|||
var success = FFMpegArguments
|
||||
.FromFileInput(TestResources.Mp4Video)
|
||||
.OutputToFile(outputFile, false)
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -447,7 +392,6 @@ public class VideoTest
|
|||
.CopyChannel()
|
||||
.WithBitStreamFilter(Channel.Video, Filter.H264_Mp4ToAnnexB)
|
||||
.ForceFormat(VideoType.MpegTs))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -459,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]
|
||||
|
|
@ -468,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));
|
||||
|
|
@ -480,7 +424,6 @@ public class VideoTest
|
|||
.FromPipeInput(input)
|
||||
.OutputToFile(output, false, opt => opt
|
||||
.ForceFormat(VideoType.Ts))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
Assert.IsTrue(success);
|
||||
|
||||
|
|
@ -498,7 +441,6 @@ public class VideoTest
|
|||
.OutputToFile(outputFile, false, opt => opt
|
||||
.Resize(200, 200)
|
||||
.WithVideoCodec(VideoCodec.LibTheora))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessAsynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -519,7 +461,6 @@ public class VideoTest
|
|||
.WithVideoFilters(filterOptions => filterOptions
|
||||
.Scale(VideoSize.Ed))
|
||||
.WithVideoCodec(VideoCodec.LibTheora))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
var analysis = FFProbe.Analyse(outputFile);
|
||||
|
|
@ -537,7 +478,6 @@ public class VideoTest
|
|||
.OutputToFile(outputFile, false, opt => opt
|
||||
.UsingMultithreading(true)
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -550,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]
|
||||
|
|
@ -559,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));
|
||||
|
|
@ -571,7 +511,6 @@ public class VideoTest
|
|||
.FromPipeInput(videoFramesSource)
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithVideoCodec(VideoCodec.LibX264))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously();
|
||||
Assert.IsTrue(success);
|
||||
}
|
||||
|
|
@ -732,8 +671,7 @@ public class VideoTest
|
|||
using var outputPath = new TemporaryFile("out.gif");
|
||||
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
||||
|
||||
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, captureTime: TimeSpan.FromSeconds(0),
|
||||
cancellationToken: TestContext.CancellationToken);
|
||||
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, captureTime: TimeSpan.FromSeconds(0));
|
||||
|
||||
var analysis = FFProbe.Analyse(outputPath);
|
||||
Assert.AreNotEqual(input.PrimaryVideoStream!.Width, analysis.PrimaryVideoStream!.Width);
|
||||
|
|
@ -749,8 +687,7 @@ public class VideoTest
|
|||
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
||||
var desiredGifSize = new Size(320, 240);
|
||||
|
||||
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, desiredGifSize, TimeSpan.FromSeconds(0),
|
||||
cancellationToken: TestContext.CancellationToken);
|
||||
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, desiredGifSize, TimeSpan.FromSeconds(0));
|
||||
|
||||
var analysis = FFProbe.Analyse(outputPath);
|
||||
Assert.AreNotEqual(input.PrimaryVideoStream!.Width, desiredGifSize.Width);
|
||||
|
|
@ -802,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);
|
||||
}
|
||||
|
|
@ -827,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));
|
||||
|
|
@ -849,13 +785,13 @@ 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);
|
||||
if (percentage < 100)
|
||||
{
|
||||
percentageDone = percentage;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTimeProgess(TimeSpan time)
|
||||
{
|
||||
|
|
@ -871,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);
|
||||
}
|
||||
|
|
@ -900,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);
|
||||
|
|
@ -913,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);
|
||||
|
|
@ -934,7 +865,6 @@ public class VideoTest
|
|||
.OutputToPipe(reader, opt => opt
|
||||
.WithVideoCodec("vp9")
|
||||
.ForceFormat("webm"))
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
resStream.Position = 0;
|
||||
|
|
@ -954,7 +884,6 @@ public class VideoTest
|
|||
.OutputToPipe(new StreamPipeSink(memoryStream), opt => opt
|
||||
.WithVideoCodec("vp9")
|
||||
.ForceFormat("webm"))
|
||||
.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously();
|
||||
|
||||
memoryStream.Position = 0;
|
||||
|
|
@ -978,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);
|
||||
|
|
@ -1003,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);
|
||||
}
|
||||
|
|
@ -1029,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);
|
||||
|
|
@ -1052,7 +976,7 @@ public class VideoTest
|
|||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
|
|
@ -1078,7 +1002,7 @@ public class VideoTest
|
|||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
|
|
@ -1102,7 +1026,7 @@ public class VideoTest
|
|||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
|
|
@ -1116,31 +1040,7 @@ public class VideoTest
|
|||
|
||||
cts.CancelAfter(300);
|
||||
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||
public void Video_Cancel_CancellationToken_Before_Throws()
|
||||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
|
||||
cts.Cancel();
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
.WithCustomArgument("-re")
|
||||
.ForceFormat("lavfi"))
|
||||
.OutputToFile(outputFile, false, opt => opt
|
||||
.WithAudioCodec(AudioCodec.Aac)
|
||||
.WithVideoCodec(VideoCodec.LibX264)
|
||||
.WithSpeedPreset(Speed.VeryFast))
|
||||
.CancellableThrough(cts.Token);
|
||||
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(TestContext.CancellationToken)
|
||||
.ProcessSynchronously());
|
||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
@ -1149,7 +1049,7 @@ public class VideoTest
|
|||
{
|
||||
using var outputFile = new TemporaryFile("out.mp4");
|
||||
|
||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
var task = FFMpegArguments
|
||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
using System.Text;
|
||||
|
||||
namespace FFMpegCore;
|
||||
|
||||
public class FFMetadataBuilder
|
||||
{
|
||||
private Dictionary<string, string> Tags { get; } = new();
|
||||
private List<FFMetadataChapter> Chapters { get; } = [];
|
||||
|
||||
public static FFMetadataBuilder Empty()
|
||||
{
|
||||
return new FFMetadataBuilder();
|
||||
}
|
||||
|
||||
public FFMetadataBuilder WithTag(string key, string value)
|
||||
{
|
||||
Tags.Add(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFMetadataBuilder WithChapter(string title, long durationMs)
|
||||
{
|
||||
Chapters.Add(new FFMetadataChapter(title, durationMs));
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFMetadataBuilder WithChapter(string title, double durationSeconds)
|
||||
{
|
||||
Chapters.Add(new FFMetadataChapter(title, Convert.ToInt64(durationSeconds * 1000)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public string GetMetadataFileContent()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(";FFMETADATA1");
|
||||
|
||||
foreach (var tag in Tags)
|
||||
{
|
||||
sb.AppendLine($"{tag.Key}={tag.Value}");
|
||||
}
|
||||
|
||||
long totalDurationMs = 0;
|
||||
foreach (var chapter in Chapters)
|
||||
{
|
||||
sb.AppendLine("[CHAPTER]");
|
||||
sb.AppendLine("TIMEBASE=1/1000");
|
||||
sb.AppendLine($"START={totalDurationMs}");
|
||||
sb.AppendLine($"END={totalDurationMs + chapter.DurationMs}");
|
||||
sb.AppendLine($"title={chapter.Title}");
|
||||
totalDurationMs += chapter.DurationMs;
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private class FFMetadataChapter(string title, long durationMs)
|
||||
{
|
||||
public string Title { get; } = title;
|
||||
public long DurationMs { get; } = durationMs;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -37,19 +37,16 @@ public static class FFMpeg
|
|||
/// <param name="size">Thumbnail size. If width or height equal 0, the other will be computed automatically.</param>
|
||||
/// <param name="streamIndex">Selected video stream index.</param>
|
||||
/// <param name="inputFileIndex">Input file index</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Bitmap with the requested snapshot.</returns>
|
||||
public static async Task<bool> SnapshotAsync(string input, string output, Size? size = null, TimeSpan? captureTime = null, int? streamIndex = null,
|
||||
int inputFileIndex = 0, CancellationToken cancellationToken = default)
|
||||
int inputFileIndex = 0)
|
||||
{
|
||||
CheckSnapshotOutputExtension(output, FileExtension.Image.All);
|
||||
|
||||
var source = await FFProbe.AnalyseAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
var source = await FFProbe.AnalyseAsync(input).ConfigureAwait(false);
|
||||
|
||||
return await SnapshotProcess(input, output, source, size, captureTime, streamIndex, inputFileIndex)
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously()
|
||||
.ConfigureAwait(false);
|
||||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
public static bool GifSnapshot(string input, string output, Size? size = null, TimeSpan? captureTime = null, TimeSpan? duration = null,
|
||||
|
|
@ -64,16 +61,14 @@ public static class FFMpeg
|
|||
}
|
||||
|
||||
public static async Task<bool> GifSnapshotAsync(string input, string output, Size? size = null, TimeSpan? captureTime = null, TimeSpan? duration = null,
|
||||
int? streamIndex = null, CancellationToken cancellationToken = default)
|
||||
int? streamIndex = null)
|
||||
{
|
||||
CheckSnapshotOutputExtension(output, [FileExtension.Gif]);
|
||||
|
||||
var source = await FFProbe.AnalyseAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
var source = await FFProbe.AnalyseAsync(input).ConfigureAwait(false);
|
||||
|
||||
return await GifSnapshotProcess(input, output, source, size, captureTime, duration, streamIndex)
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously()
|
||||
.ConfigureAwait(false);
|
||||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
private static FFMpegArgumentProcessor SnapshotProcess(string input, string output, IMediaAnalysis source, Size? size = null, TimeSpan? captureTime = null,
|
||||
|
|
@ -137,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)
|
||||
|
|
@ -326,15 +320,11 @@ public static class FFMpeg
|
|||
/// <param name="output">Output video file.</param>
|
||||
/// <param name="startTime">The start time of when the sub video needs to start</param>
|
||||
/// <param name="endTime">The end time of where the sub video needs to end</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Output video information.</returns>
|
||||
public static async Task<bool> SubVideoAsync(string input, string output, TimeSpan startTime, TimeSpan endTime,
|
||||
CancellationToken cancellationToken = default)
|
||||
public static async Task<bool> SubVideoAsync(string input, string output, TimeSpan startTime, TimeSpan endTime)
|
||||
{
|
||||
return await BaseSubVideo(input, output, startTime, endTime)
|
||||
.CancellableThrough(cancellationToken)
|
||||
.ProcessAsynchronously()
|
||||
.ConfigureAwait(false);
|
||||
.ProcessAsynchronously();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ public class FFMpegArgumentProcessor
|
|||
private static readonly Regex ProgressRegex = new(@"time=(\d\d:\d\d:\d\d.\d\d?)", RegexOptions.Compiled);
|
||||
private readonly List<Action<FFOptions>> _configurations;
|
||||
private readonly FFMpegArguments _ffMpegArguments;
|
||||
private CancellationTokenRegistration? _cancellationTokenRegistration;
|
||||
private bool _cancelled;
|
||||
private FFMpegLogLevel? _logLevel;
|
||||
private Action<string>? _onError;
|
||||
private Action<string>? _onOutput;
|
||||
|
|
@ -71,22 +69,15 @@ public class FFMpegArgumentProcessor
|
|||
return this;
|
||||
}
|
||||
|
||||
private void Cancel(int timeout)
|
||||
{
|
||||
_cancelled = true;
|
||||
CancelEvent?.Invoke(this, timeout);
|
||||
}
|
||||
|
||||
public FFMpegArgumentProcessor CancellableThrough(out Action cancel, int timeout = 0)
|
||||
{
|
||||
cancel = () => Cancel(timeout);
|
||||
cancel = () => CancelEvent?.Invoke(this, timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FFMpegArgumentProcessor CancellableThrough(CancellationToken token, int timeout = 0)
|
||||
{
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
_cancellationTokenRegistration = token.Register(() => Cancel(timeout));
|
||||
token.Register(() => CancelEvent?.Invoke(this, timeout));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -110,8 +101,7 @@ public class FFMpegArgumentProcessor
|
|||
public bool ProcessSynchronously(bool throwOnError = true, FFOptions? ffMpegOptions = null)
|
||||
{
|
||||
var options = GetConfiguredOptions(ffMpegOptions);
|
||||
var processArguments = PrepareProcessArguments(options);
|
||||
using var cancellationTokenSource = new CancellationTokenSource();
|
||||
var processArguments = PrepareProcessArguments(options, out var cancellationTokenSource);
|
||||
|
||||
IProcessResult? processResult = null;
|
||||
try
|
||||
|
|
@ -132,8 +122,7 @@ public class FFMpegArgumentProcessor
|
|||
public async Task<bool> ProcessAsynchronously(bool throwOnError = true, FFOptions? ffMpegOptions = null)
|
||||
{
|
||||
var options = GetConfiguredOptions(ffMpegOptions);
|
||||
var processArguments = PrepareProcessArguments(options);
|
||||
using var cancellationTokenSource = new CancellationTokenSource();
|
||||
var processArguments = PrepareProcessArguments(options, out var cancellationTokenSource);
|
||||
|
||||
IProcessResult? processResult = null;
|
||||
try
|
||||
|
|
@ -154,40 +143,21 @@ public class FFMpegArgumentProcessor
|
|||
private async Task<IProcessResult> Process(ProcessArguments processArguments, CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
IProcessResult processResult = null!;
|
||||
if (_cancelled)
|
||||
{
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
throw new OperationCanceledException("cancelled before starting processing");
|
||||
}
|
||||
|
||||
_ffMpegArguments.Pre();
|
||||
|
||||
using var instance = processArguments.Start();
|
||||
var cancelled = false;
|
||||
|
||||
void OnCancelEvent(object sender, int timeout)
|
||||
{
|
||||
ExecuteIgnoringFinishedProcessExceptions(() => instance.SendInput("q"));
|
||||
cancelled = true;
|
||||
instance.SendInput("q");
|
||||
|
||||
if (!cancellationTokenSource.Token.WaitHandle.WaitOne(timeout, true))
|
||||
{
|
||||
cancellationTokenSource.Cancel();
|
||||
ExecuteIgnoringFinishedProcessExceptions(() => instance.Kill());
|
||||
}
|
||||
|
||||
static void ExecuteIgnoringFinishedProcessExceptions(Action action)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (Instances.Exceptions.InstanceProcessAlreadyExitedException)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
instance.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,9 +172,8 @@ public class FFMpegArgumentProcessor
|
|||
_ffMpegArguments.Post();
|
||||
}), _ffMpegArguments.During(cancellationTokenSource.Token)).ConfigureAwait(false);
|
||||
|
||||
if (_cancelled)
|
||||
if (cancelled)
|
||||
{
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
throw new OperationCanceledException("ffmpeg processing was cancelled");
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +182,6 @@ public class FFMpegArgumentProcessor
|
|||
finally
|
||||
{
|
||||
CancelEvent -= OnCancelEvent;
|
||||
_cancellationTokenRegistration?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +214,8 @@ public class FFMpegArgumentProcessor
|
|||
return options;
|
||||
}
|
||||
|
||||
private ProcessArguments PrepareProcessArguments(FFOptions ffOptions)
|
||||
private ProcessArguments PrepareProcessArguments(FFOptions ffOptions,
|
||||
out CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
FFMpegHelper.RootExceptionCheck();
|
||||
FFMpegHelper.VerifyFFMpegExists(ffOptions);
|
||||
|
|
@ -276,6 +245,7 @@ public class FFMpegArgumentProcessor
|
|||
WorkingDirectory = ffOptions.WorkingDirectory
|
||||
};
|
||||
var processArguments = new ProcessArguments(startInfo);
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
if (_onOutput != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -109,11 +109,6 @@ public sealed class FFMpegArguments : FFMpegArgumentsBase
|
|||
return WithInput(new MetaDataArgument(content), addArguments);
|
||||
}
|
||||
|
||||
public FFMpegArguments AddMetaData(FFMetadataBuilder metaDataBuilder, Action<FFMpegArgumentOptions>? addArguments = null)
|
||||
{
|
||||
return WithInput(new MetaDataArgument(metaDataBuilder.GetMetadataFileContent()), addArguments);
|
||||
}
|
||||
|
||||
public FFMpegArguments AddMetaData(IReadOnlyMetaData metaData, Action<FFMpegArgumentOptions>? addArguments = null)
|
||||
{
|
||||
return WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
<PropertyGroup>
|
||||
<IsPackable>true</IsPackable>
|
||||
<Description>A .NET Standard FFMpeg/FFProbe wrapper for easily integrating media analysis and conversion into your .NET applications</Description>
|
||||
<PackageVersion>5.4.0</PackageVersion>
|
||||
<PackageVersion>5.3.0</PackageVersion>
|
||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||
<PackageReleaseNotes>
|
||||
- Fixed exception thrown on cancelling ffprobe analysis - by snechaev
|
||||
- Support for cancellationtoken in SnapsnotAsync methods - by snechaev
|
||||
- Added FFMetadataBuilder - by rosenbjerg
|
||||
- Fix JoinImageSequence by passing framerate argument to input as well as output - by rosenbjerg
|
||||
- Change fps input from int to double - by rosenbjerg
|
||||
- Fix GetCreationTime method on ITagsContainer - by rosenbjerg
|
||||
- **Fixed race condition on Named pipe dispose/disconnect** by techtel-pstevens
|
||||
- **More extensions for snapshot function(jpg, bmp, webp)** by GorobVictor
|
||||
- **Include more GUID characters in pipe path** by reima, rosenbjerg
|
||||
- **Updated dependencies and minor cleanup**: by rosenbjerg
|
||||
</PackageReleaseNotes>
|
||||
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
||||
<Authors>Malte Rosenbjerg, Vlad Jerca, Max Bagryantsev</Authors>
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ public static class FFProbe
|
|||
|
||||
var instance = PrepareStreamAnalysisInstance(filePath, ffOptions ?? GlobalFFOptions.Current, customArguments);
|
||||
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfExitCodeNotZero(result);
|
||||
|
||||
return ParseOutput(result);
|
||||
|
|
@ -124,7 +123,6 @@ public static class FFProbe
|
|||
{
|
||||
var instance = PrepareStreamAnalysisInstance(uri.AbsoluteUri, ffOptions ?? GlobalFFOptions.Current, customArguments);
|
||||
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfExitCodeNotZero(result);
|
||||
|
||||
return ParseOutput(result);
|
||||
|
|
@ -152,7 +150,6 @@ public static class FFProbe
|
|||
}
|
||||
|
||||
var result = await task.ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ThrowIfExitCodeNotZero(result);
|
||||
|
||||
pipeArgument.Post();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ public static class ProcessArgumentsExtensions
|
|||
public static async Task<IProcessResult> StartAndWaitForExitAsync(this ProcessArguments processArguments, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var instance = processArguments.Start();
|
||||
return await instance.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
||||
return await instance.WaitForExitAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue