mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-16 11:05:44 +00:00
Compare commits
1 commit
ac441eefd6
...
2b66841fd9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b66841fd9 |
12 changed files with 42 additions and 354 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="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="streamIndex">Selected video stream index.</param>
|
||||||
/// <param name="inputFileIndex">Input file index</param>
|
/// <param name="inputFileIndex">Input file index</param>
|
||||||
/// <param name="cancellationToken">Cancellation token</param>
|
|
||||||
/// <returns>Bitmap with the requested snapshot.</returns>
|
/// <returns>Bitmap with the requested snapshot.</returns>
|
||||||
public static async Task<SKBitmap> SnapshotAsync(string input, Size? size = null, TimeSpan? captureTime = null, int? streamIndex = null,
|
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);
|
var (arguments, outputOptions) = SnapshotArgumentBuilder.BuildSnapshotArguments(input, source, size, captureTime, streamIndex, inputFileIndex);
|
||||||
using var ms = new MemoryStream();
|
using var ms = new MemoryStream();
|
||||||
|
|
||||||
await arguments
|
await arguments
|
||||||
.OutputToPipe(new StreamPipeSink(ms), options => outputOptions(options
|
.OutputToPipe(new StreamPipeSink(ms), options => outputOptions(options
|
||||||
.ForceFormat("rawvideo")))
|
.ForceFormat("rawvideo")))
|
||||||
.CancellableThrough(cancellationToken)
|
.ProcessAsynchronously();
|
||||||
.ProcessAsynchronously()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
return SKBitmap.Decode(ms);
|
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="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="streamIndex">Selected video stream index.</param>
|
||||||
/// <param name="inputFileIndex">Input file index</param>
|
/// <param name="inputFileIndex">Input file index</param>
|
||||||
/// <param name="cancellationToken">Cancellation token</param>
|
|
||||||
/// <returns>Bitmap with the requested snapshot.</returns>
|
/// <returns>Bitmap with the requested snapshot.</returns>
|
||||||
public static async Task<Bitmap> SnapshotAsync(string input, Size? size = null, TimeSpan? captureTime = null, int? streamIndex = null,
|
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);
|
var (arguments, outputOptions) = SnapshotArgumentBuilder.BuildSnapshotArguments(input, source, size, captureTime, streamIndex, inputFileIndex);
|
||||||
using var ms = new MemoryStream();
|
using var ms = new MemoryStream();
|
||||||
|
|
||||||
await arguments
|
await arguments
|
||||||
.OutputToPipe(new StreamPipeSink(ms), options => outputOptions(options
|
.OutputToPipe(new StreamPipeSink(ms), options => outputOptions(options
|
||||||
.ForceFormat("rawvideo")))
|
.ForceFormat("rawvideo")))
|
||||||
.CancellableThrough(cancellationToken)
|
.ProcessAsynchronously();
|
||||||
.ProcessAsynchronously()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
return new Bitmap(ms);
|
return new Bitmap(ms);
|
||||||
|
|
|
||||||
|
|
@ -93,14 +93,6 @@ public class ArgumentBuilderTest
|
||||||
Assert.AreEqual("-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\"", str);
|
Assert.AreEqual("-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\"", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void Builder_BuildString_DemuxConcat()
|
|
||||||
{
|
|
||||||
var str = FFMpegArguments.FromDemuxConcatInput(_concatFiles).OutputToFile("output.mp4", false).Arguments;
|
|
||||||
Assert.Contains("-f concat -safe 0 -i", str);
|
|
||||||
Assert.Contains("\"output.mp4\"", str);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Copy_Audio()
|
public void Builder_BuildString_Copy_Audio()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using FFMpegCore.Exceptions;
|
using FFMpegCore.Test.Resources;
|
||||||
using FFMpegCore.Helpers;
|
|
||||||
using FFMpegCore.Test.Resources;
|
|
||||||
|
|
||||||
namespace FFMpegCore.Test;
|
namespace FFMpegCore.Test;
|
||||||
|
|
||||||
|
|
@ -288,70 +286,6 @@ public class FFProbeTests
|
||||||
Assert.AreEqual(3, info.Duration.Seconds);
|
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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Probe_Success_Output_Data()
|
public void Probe_Success_Output_Data()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -82,40 +82,6 @@ public class VideoTest
|
||||||
Assert.IsTrue(success);
|
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]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_ToH265_MKV_Args()
|
public void Video_ToH265_MKV_Args()
|
||||||
|
|
@ -154,7 +120,7 @@ public class VideoTest
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||||
|
|
||||||
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(64, pixelFormat, 256, 256));
|
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 256, 256));
|
||||||
var success = FFMpegArguments
|
var success = FFMpegArguments
|
||||||
.FromPipeInput(videoFramesSource)
|
.FromPipeInput(videoFramesSource)
|
||||||
.OutputToFile(outputFile, false, opt => opt
|
.OutputToFile(outputFile, false, opt => opt
|
||||||
|
|
@ -474,7 +440,7 @@ public class VideoTest
|
||||||
private static async Task Video_ToTS_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
private static async Task Video_ToTS_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using var output = new TemporaryFile($"out{VideoType.Ts.Extension}");
|
using var output = new TemporaryFile($"out{VideoType.Ts.Extension}");
|
||||||
var input = new RawVideoPipeSource(BitmapSource.CreateBitmaps(64, pixelFormat, 256, 256));
|
var input = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 256, 256));
|
||||||
|
|
||||||
var success = await FFMpegArguments
|
var success = await FFMpegArguments
|
||||||
.FromPipeInput(input)
|
.FromPipeInput(input)
|
||||||
|
|
@ -511,7 +477,7 @@ public class VideoTest
|
||||||
public void RawVideoPipeSource_Ogv_Scale(SKColorType pixelFormat)
|
public void RawVideoPipeSource_Ogv_Scale(SKColorType pixelFormat)
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile($"out{VideoType.Ogv.Extension}");
|
using var outputFile = new TemporaryFile($"out{VideoType.Ogv.Extension}");
|
||||||
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(64, pixelFormat, 256, 256));
|
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 256, 256));
|
||||||
|
|
||||||
FFMpegArguments
|
FFMpegArguments
|
||||||
.FromPipeInput(videoFramesSource)
|
.FromPipeInput(videoFramesSource)
|
||||||
|
|
@ -565,7 +531,7 @@ public class VideoTest
|
||||||
private static void Video_ToMP4_Resize_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
private static void Video_ToMP4_Resize_Args_Pipe_Internal(dynamic pixelFormat, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
using var outputFile = new TemporaryFile($"out{VideoType.Mp4.Extension}");
|
||||||
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(64, pixelFormat, 256, 256));
|
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 256, 256));
|
||||||
|
|
||||||
var success = FFMpegArguments
|
var success = FFMpegArguments
|
||||||
.FromPipeInput(videoFramesSource)
|
.FromPipeInput(videoFramesSource)
|
||||||
|
|
@ -589,19 +555,6 @@ public class VideoTest
|
||||||
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
|
||||||
[OsSpecificTestMethod(OsPlatforms.Windows)]
|
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
|
||||||
public async Task Video_SnapshotAsync_InMemory_SystemDrawingCommon()
|
|
||||||
{
|
|
||||||
using var bitmap = await FFMpegImage.SnapshotAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
|
||||||
|
|
||||||
var input = await FFProbe.AnalyseAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream!.Width, bitmap.Width);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Height, bitmap.Height);
|
|
||||||
Assert.AreEqual(bitmap.RawFormat, ImageFormat.Png);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Snapshot_InMemory_SkiaSharp()
|
public void Video_Snapshot_InMemory_SkiaSharp()
|
||||||
|
|
@ -615,19 +568,6 @@ public class VideoTest
|
||||||
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
|
||||||
public async Task Video_SnapshotAsync_InMemory_SkiaSharp()
|
|
||||||
{
|
|
||||||
using var bitmap = await Extensions.SkiaSharp.FFMpegImage.SnapshotAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
|
||||||
|
|
||||||
var input = await FFProbe.AnalyseAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream!.Width, bitmap.Width);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Height, bitmap.Height);
|
|
||||||
// Note: The resulting ColorType is dependent on the execution environment and therefore not assessed,
|
|
||||||
// e.g. Bgra8888 on Windows and Rgba8888 on macOS.
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Snapshot_Png_PersistSnapshot()
|
public void Video_Snapshot_Png_PersistSnapshot()
|
||||||
|
|
@ -643,21 +583,6 @@ public class VideoTest
|
||||||
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
|
||||||
public async Task Video_SnapshotAsync_Png_PersistSnapshot()
|
|
||||||
{
|
|
||||||
using var outputPath = new TemporaryFile("out.png");
|
|
||||||
var input = await FFProbe.AnalyseAsync(TestResources.Mp4Video, cancellationToken: TestContext.CancellationToken);
|
|
||||||
|
|
||||||
await FFMpeg.SnapshotAsync(TestResources.Mp4Video, outputPath, cancellationToken: TestContext.CancellationToken);
|
|
||||||
|
|
||||||
var analysis = FFProbe.Analyse(outputPath);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream!.Width, analysis.PrimaryVideoStream!.Width);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Height, analysis.PrimaryVideoStream!.Height);
|
|
||||||
Assert.AreEqual("png", analysis.PrimaryVideoStream!.CodecName);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Snapshot_Jpg_PersistSnapshot()
|
public void Video_Snapshot_Jpg_PersistSnapshot()
|
||||||
|
|
@ -773,8 +698,7 @@ public class VideoTest
|
||||||
using var outputPath = new TemporaryFile("out.gif");
|
using var outputPath = new TemporaryFile("out.gif");
|
||||||
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
||||||
|
|
||||||
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, captureTime: TimeSpan.FromSeconds(0),
|
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, captureTime: TimeSpan.FromSeconds(0));
|
||||||
cancellationToken: TestContext.CancellationToken);
|
|
||||||
|
|
||||||
var analysis = FFProbe.Analyse(outputPath);
|
var analysis = FFProbe.Analyse(outputPath);
|
||||||
Assert.AreNotEqual(input.PrimaryVideoStream!.Width, analysis.PrimaryVideoStream!.Width);
|
Assert.AreNotEqual(input.PrimaryVideoStream!.Width, analysis.PrimaryVideoStream!.Width);
|
||||||
|
|
@ -790,8 +714,7 @@ public class VideoTest
|
||||||
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
||||||
var desiredGifSize = new Size(320, 240);
|
var desiredGifSize = new Size(320, 240);
|
||||||
|
|
||||||
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, desiredGifSize, TimeSpan.FromSeconds(0),
|
await FFMpeg.GifSnapshotAsync(TestResources.Mp4Video, outputPath, desiredGifSize, TimeSpan.FromSeconds(0));
|
||||||
cancellationToken: TestContext.CancellationToken);
|
|
||||||
|
|
||||||
var analysis = FFProbe.Analyse(outputPath);
|
var analysis = FFProbe.Analyse(outputPath);
|
||||||
Assert.AreNotEqual(input.PrimaryVideoStream!.Width, desiredGifSize.Width);
|
Assert.AreNotEqual(input.PrimaryVideoStream!.Width, desiredGifSize.Width);
|
||||||
|
|
@ -822,46 +745,6 @@ public class VideoTest
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
|
||||||
public void Video_Convert_Webm()
|
|
||||||
{
|
|
||||||
using var outputPath = new TemporaryFile("out.webm");
|
|
||||||
|
|
||||||
var success = FFMpeg.Convert(TestResources.Mp4Video, outputPath, VideoType.WebM);
|
|
||||||
Assert.IsTrue(success);
|
|
||||||
Assert.IsTrue(File.Exists(outputPath));
|
|
||||||
|
|
||||||
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
|
||||||
var result = FFProbe.Analyse(outputPath);
|
|
||||||
Assert.AreEqual(input.Duration.Days, result.Duration.Days);
|
|
||||||
Assert.AreEqual(input.Duration.Hours, result.Duration.Hours);
|
|
||||||
Assert.AreEqual(input.Duration.Minutes, result.Duration.Minutes);
|
|
||||||
Assert.AreEqual(input.Duration.Seconds, result.Duration.Seconds);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream!.Height, result.PrimaryVideoStream!.Height);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
|
||||||
public void Video_Convert_Ogv()
|
|
||||||
{
|
|
||||||
using var outputPath = new TemporaryFile("out.ogv");
|
|
||||||
|
|
||||||
var success = FFMpeg.Convert(TestResources.Mp4Video, outputPath, VideoType.Ogv);
|
|
||||||
Assert.IsTrue(success);
|
|
||||||
Assert.IsTrue(File.Exists(outputPath));
|
|
||||||
|
|
||||||
var input = FFProbe.Analyse(TestResources.Mp4Video);
|
|
||||||
var result = FFProbe.Analyse(outputPath);
|
|
||||||
Assert.AreEqual(input.Duration.Days, result.Duration.Days);
|
|
||||||
Assert.AreEqual(input.Duration.Hours, result.Duration.Hours);
|
|
||||||
Assert.AreEqual(input.Duration.Minutes, result.Duration.Minutes);
|
|
||||||
Assert.AreEqual(input.Duration.Seconds, result.Duration.Seconds);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream!.Height, result.PrimaryVideoStream!.Height);
|
|
||||||
Assert.AreEqual(input.PrimaryVideoStream.Width, result.PrimaryVideoStream.Width);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(2 * BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(2 * BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Join_Image_Sequence()
|
public void Video_Join_Image_Sequence()
|
||||||
|
|
@ -1008,7 +891,7 @@ public class VideoTest
|
||||||
{
|
{
|
||||||
using var resStream = new MemoryStream();
|
using var resStream = new MemoryStream();
|
||||||
var reader = new StreamPipeSink(resStream);
|
var reader = new StreamPipeSink(resStream);
|
||||||
var writer = new RawVideoPipeSource(BitmapSource.CreateBitmaps(64, pixelFormat, 128, 128));
|
var writer = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, pixelFormat, 128, 128));
|
||||||
|
|
||||||
FFMpegArguments
|
FFMpegArguments
|
||||||
.FromPipeInput(writer)
|
.FromPipeInput(writer)
|
||||||
|
|
@ -1133,7 +1016,7 @@ public class VideoTest
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile("out.mp4");
|
using var outputFile = new TemporaryFile("out.mp4");
|
||||||
|
|
||||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
var cts = new CancellationTokenSource();
|
||||||
|
|
||||||
var task = FFMpegArguments
|
var task = FFMpegArguments
|
||||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||||
|
|
@ -1144,6 +1027,7 @@ public class VideoTest
|
||||||
.WithVideoCodec(VideoCodec.LibX264)
|
.WithVideoCodec(VideoCodec.LibX264)
|
||||||
.WithSpeedPreset(Speed.VeryFast))
|
.WithSpeedPreset(Speed.VeryFast))
|
||||||
.CancellableThrough(cts.Token)
|
.CancellableThrough(cts.Token)
|
||||||
|
.CancellableThrough(TestContext.CancellationToken)
|
||||||
.ProcessAsynchronously(false);
|
.ProcessAsynchronously(false);
|
||||||
|
|
||||||
cts.CancelAfter(300);
|
cts.CancelAfter(300);
|
||||||
|
|
@ -1159,7 +1043,7 @@ public class VideoTest
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile("out.mp4");
|
using var outputFile = new TemporaryFile("out.mp4");
|
||||||
|
|
||||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
var cts = new CancellationTokenSource();
|
||||||
|
|
||||||
var task = FFMpegArguments
|
var task = FFMpegArguments
|
||||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||||
|
|
@ -1170,6 +1054,7 @@ public class VideoTest
|
||||||
.WithVideoCodec(VideoCodec.LibX264)
|
.WithVideoCodec(VideoCodec.LibX264)
|
||||||
.WithSpeedPreset(Speed.VeryFast))
|
.WithSpeedPreset(Speed.VeryFast))
|
||||||
.CancellableThrough(cts.Token)
|
.CancellableThrough(cts.Token)
|
||||||
|
.CancellableThrough(TestContext.CancellationToken)
|
||||||
.ProcessAsynchronously();
|
.ProcessAsynchronously();
|
||||||
|
|
||||||
cts.CancelAfter(300);
|
cts.CancelAfter(300);
|
||||||
|
|
@ -1183,7 +1068,7 @@ public class VideoTest
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile("out.mp4");
|
using var outputFile = new TemporaryFile("out.mp4");
|
||||||
|
|
||||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
var cts = new CancellationTokenSource();
|
||||||
|
|
||||||
var task = FFMpegArguments
|
var task = FFMpegArguments
|
||||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||||
|
|
@ -1203,12 +1088,13 @@ public class VideoTest
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
||||||
public void Video_Cancel_CancellationToken_BeforeProcessing_Throws()
|
public void Video_Cancel_CancellationToken_Before_Throws()
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile("out.mp4");
|
using var outputFile = new TemporaryFile("out.mp4");
|
||||||
|
|
||||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
var cts = new CancellationTokenSource();
|
||||||
|
|
||||||
|
cts.Cancel();
|
||||||
var task = FFMpegArguments
|
var task = FFMpegArguments
|
||||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||||
.WithCustomArgument("-re")
|
.WithCustomArgument("-re")
|
||||||
|
|
@ -1219,29 +1105,8 @@ public class VideoTest
|
||||||
.WithSpeedPreset(Speed.VeryFast))
|
.WithSpeedPreset(Speed.VeryFast))
|
||||||
.CancellableThrough(cts.Token);
|
.CancellableThrough(cts.Token);
|
||||||
|
|
||||||
cts.Cancel();
|
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(TestContext.CancellationToken)
|
||||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
|
.ProcessSynchronously());
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
|
|
||||||
public void Video_Cancel_CancellationToken_BeforePassing_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));
|
|
||||||
|
|
||||||
Assert.ThrowsExactly<OperationCanceledException>(() => task.CancellableThrough(cts.Token));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
@ -1250,7 +1115,7 @@ public class VideoTest
|
||||||
{
|
{
|
||||||
using var outputFile = new TemporaryFile("out.mp4");
|
using var outputFile = new TemporaryFile("out.mp4");
|
||||||
|
|
||||||
using var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.CancellationToken);
|
var cts = new CancellationTokenSource();
|
||||||
|
|
||||||
var task = FFMpegArguments
|
var task = FFMpegArguments
|
||||||
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
|
||||||
|
|
|
||||||
|
|
@ -1,61 +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)
|
|
||||||
{
|
|
||||||
return WithChapter(title, Convert.ToInt64(durationSeconds * 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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="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="streamIndex">Selected video stream index.</param>
|
||||||
/// <param name="inputFileIndex">Input file index</param>
|
/// <param name="inputFileIndex">Input file index</param>
|
||||||
/// <param name="cancellationToken">Cancellation token</param>
|
|
||||||
/// <returns>Bitmap with the requested snapshot.</returns>
|
/// <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,
|
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);
|
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)
|
return await SnapshotProcess(input, output, source, size, captureTime, streamIndex, inputFileIndex)
|
||||||
.CancellableThrough(cancellationToken)
|
.ProcessAsynchronously();
|
||||||
.ProcessAsynchronously()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool GifSnapshot(string input, string output, Size? size = null, TimeSpan? captureTime = null, TimeSpan? duration = null,
|
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,
|
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]);
|
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)
|
return await GifSnapshotProcess(input, output, source, size, captureTime, duration, streamIndex)
|
||||||
.CancellableThrough(cancellationToken)
|
.ProcessAsynchronously();
|
||||||
.ProcessAsynchronously()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FFMpegArgumentProcessor SnapshotProcess(string input, string output, IMediaAnalysis source, Size? size = null, TimeSpan? captureTime = null,
|
private static FFMpegArgumentProcessor SnapshotProcess(string input, string output, IMediaAnalysis source, Size? size = null, TimeSpan? captureTime = null,
|
||||||
|
|
@ -297,7 +292,7 @@ public static class FFMpeg
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(input) != Path.GetExtension(output))
|
if (Path.GetExtension(input) != Path.GetExtension(output))
|
||||||
{
|
{
|
||||||
output = Path.ChangeExtension(output, Path.GetExtension(input));
|
output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output), Path.GetExtension(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
return FFMpegArguments
|
return FFMpegArguments
|
||||||
|
|
@ -326,15 +321,11 @@ public static class FFMpeg
|
||||||
/// <param name="output">Output video file.</param>
|
/// <param name="output">Output video file.</param>
|
||||||
/// <param name="startTime">The start time of when the sub video needs to start</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="endTime">The end time of where the sub video needs to end</param>
|
||||||
/// <param name="cancellationToken">Cancellation token</param>
|
|
||||||
/// <returns>Output video information.</returns>
|
/// <returns>Output video information.</returns>
|
||||||
public static async Task<bool> SubVideoAsync(string input, string output, TimeSpan startTime, TimeSpan endTime,
|
public static async Task<bool> SubVideoAsync(string input, string output, TimeSpan startTime, TimeSpan endTime)
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
{
|
||||||
return await BaseSubVideo(input, output, startTime, endTime)
|
return await BaseSubVideo(input, output, startTime, endTime)
|
||||||
.CancellableThrough(cancellationToken)
|
.ProcessAsynchronously();
|
||||||
.ProcessAsynchronously()
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,6 @@ public class FFMpegArgumentProcessor
|
||||||
|
|
||||||
public FFMpegArgumentProcessor CancellableThrough(CancellationToken token, int timeout = 0)
|
public FFMpegArgumentProcessor CancellableThrough(CancellationToken token, int timeout = 0)
|
||||||
{
|
{
|
||||||
token.ThrowIfCancellationRequested();
|
|
||||||
_cancellationTokenRegistration?.Dispose();
|
_cancellationTokenRegistration?.Dispose();
|
||||||
_cancellationTokenRegistration = token.Register(() => Cancel(timeout));
|
_cancellationTokenRegistration = token.Register(() => Cancel(timeout));
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -167,28 +166,12 @@ public class FFMpegArgumentProcessor
|
||||||
|
|
||||||
void OnCancelEvent(object sender, int timeout)
|
void OnCancelEvent(object sender, int timeout)
|
||||||
{
|
{
|
||||||
ExecuteIgnoringFinishedProcessExceptions(() => instance.SendInput("q"));
|
instance.SendInput("q");
|
||||||
|
|
||||||
if (!cancellationTokenSource.Token.WaitHandle.WaitOne(timeout, true))
|
if (!cancellationTokenSource.Token.WaitHandle.WaitOne(timeout, true))
|
||||||
{
|
{
|
||||||
cancellationTokenSource.Cancel();
|
cancellationTokenSource.Cancel();
|
||||||
ExecuteIgnoringFinishedProcessExceptions(() => instance.Kill());
|
instance.Kill();
|
||||||
}
|
|
||||||
|
|
||||||
static void ExecuteIgnoringFinishedProcessExceptions(Action action)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
catch (Instances.Exceptions.InstanceProcessAlreadyExitedException)
|
|
||||||
{
|
|
||||||
//ignore
|
|
||||||
}
|
|
||||||
catch (ObjectDisposedException)
|
|
||||||
{
|
|
||||||
//ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,11 +109,6 @@ public sealed class FFMpegArguments : FFMpegArgumentsBase
|
||||||
return WithInput(new MetaDataArgument(content), addArguments);
|
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)
|
public FFMpegArguments AddMetaData(IReadOnlyMetaData metaData, Action<FFMpegArgumentOptions>? addArguments = null)
|
||||||
{
|
{
|
||||||
return WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments);
|
return WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments);
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,13 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
<Description>A .NET Standard FFMpeg/FFProbe wrapper for easily integrating media analysis and conversion into your .NET applications</Description>
|
<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>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
- Fixed exception thrown on cancelling ffprobe analysis - by snechaev
|
- **Fixed race condition on Named pipe dispose/disconnect** by techtel-pstevens
|
||||||
- Support for cancellationtoken in SnapsnotAsync methods - by snechaev
|
- **More extensions for snapshot function(jpg, bmp, webp)** by GorobVictor
|
||||||
- Added FFMetadataBuilder - by rosenbjerg
|
- **Include more GUID characters in pipe path** by reima, rosenbjerg
|
||||||
- Fix JoinImageSequence by passing framerate argument to input as well as output - by rosenbjerg
|
- **Updated dependencies and minor cleanup**: by rosenbjerg
|
||||||
- Change fps input from int to double - by rosenbjerg
|
|
||||||
- Fix GetCreationTime method on ITagsContainer - by rosenbjerg
|
|
||||||
</PackageReleaseNotes>
|
</PackageReleaseNotes>
|
||||||
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
||||||
<Authors>Malte Rosenbjerg, Vlad Jerca, Max Bagryantsev</Authors>
|
<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 instance = PrepareStreamAnalysisInstance(filePath, ffOptions ?? GlobalFFOptions.Current, customArguments);
|
||||||
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
ThrowIfExitCodeNotZero(result);
|
ThrowIfExitCodeNotZero(result);
|
||||||
|
|
||||||
return ParseOutput(result);
|
return ParseOutput(result);
|
||||||
|
|
@ -124,7 +123,6 @@ public static class FFProbe
|
||||||
{
|
{
|
||||||
var instance = PrepareStreamAnalysisInstance(uri.AbsoluteUri, ffOptions ?? GlobalFFOptions.Current, customArguments);
|
var instance = PrepareStreamAnalysisInstance(uri.AbsoluteUri, ffOptions ?? GlobalFFOptions.Current, customArguments);
|
||||||
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
var result = await instance.StartAndWaitForExitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
ThrowIfExitCodeNotZero(result);
|
ThrowIfExitCodeNotZero(result);
|
||||||
|
|
||||||
return ParseOutput(result);
|
return ParseOutput(result);
|
||||||
|
|
@ -152,7 +150,6 @@ public static class FFProbe
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = await task.ConfigureAwait(false);
|
var result = await task.ConfigureAwait(false);
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
ThrowIfExitCodeNotZero(result);
|
ThrowIfExitCodeNotZero(result);
|
||||||
|
|
||||||
pipeArgument.Post();
|
pipeArgument.Post();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,6 @@ public static class ProcessArgumentsExtensions
|
||||||
public static async Task<IProcessResult> StartAndWaitForExitAsync(this ProcessArguments processArguments, CancellationToken cancellationToken = default)
|
public static async Task<IProcessResult> StartAndWaitForExitAsync(this ProcessArguments processArguments, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using var instance = processArguments.Start();
|
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