From 01bded84621b4aba4cb7804effc1f587fa87a64a Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Thu, 29 Oct 2020 00:16:58 +0100 Subject: [PATCH 1/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fb7abe..7889a95 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # FFMpegCore -[![NuGet Badge](https://buildstats.info/nuget/FFMpegCore)](https://www.nuget.org/packages/FFMpegCore/) [![CI](https://github.com/rosenbjerg/FFMpegCore/workflows/CI/badge.svg)](https://github.com/rosenbjerg/FFMpegCore/actions?query=workflow%3ACI) +[![NuGet Badge](https://buildstats.info/nuget/FFMpegCore)](https://www.nuget.org/packages/FFMpegCore/) +[![GitHub issues](https://img.shields.io/github/issues/rosenbjerg/FFMpegCore)](https://github.com/rosenbjerg/FFMpegCore/issues) +[![GitHub stars](https://img.shields.io/github/stars/rosenbjerg/FFMpegCore)](https://github.com/rosenbjerg/FFMpegCore/stargazers) # Setup From 928e501033c2c4c5752cce2ee41361e9d53959ef Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Thu, 29 Oct 2020 00:28:46 +0100 Subject: [PATCH 2/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7889a95..ffc7aeb 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![NuGet Badge](https://buildstats.info/nuget/FFMpegCore)](https://www.nuget.org/packages/FFMpegCore/) [![GitHub issues](https://img.shields.io/github/issues/rosenbjerg/FFMpegCore)](https://github.com/rosenbjerg/FFMpegCore/issues) [![GitHub stars](https://img.shields.io/github/stars/rosenbjerg/FFMpegCore)](https://github.com/rosenbjerg/FFMpegCore/stargazers) +[![GitHub](https://img.shields.io/github/license/rosenbjerg/FFMpegCore)](https://github.com/rosenbjerg/FFMpegCore/blob/master/LICENSE) # Setup From 1bcc9fe3bd64f67b907a8cc82c5a6aabdaf9cd09 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Mon, 9 Nov 2020 21:12:34 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ffc7aeb..0012def 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,7 @@ The root and temp directory for the ffmpeg binaries can be configured via the `f + ### License From 5ba2ed97cf1401fc539ec82e70c7c6db6e1023bf Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Wed, 25 Nov 2020 16:15:16 +0100 Subject: [PATCH 4/5] Update dependencies and add StreamPipeSink constructor --- FFMpegCore.Test/FFMpegCore.Test.csproj | 4 ++-- .../FFMpeg/Arguments/InputPipeArgument.cs | 2 +- .../FFMpeg/Arguments/OutputPipeArgument.cs | 2 +- FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 2 +- FFMpegCore/FFMpeg/FFMpegOptions.cs | 2 +- FFMpegCore/FFMpeg/Pipes/IPipeSink.cs | 2 +- FFMpegCore/FFMpeg/Pipes/IPipeSource.cs | 2 +- FFMpegCore/FFMpeg/Pipes/RawVideoPipeSource.cs | 2 +- FFMpegCore/FFMpeg/Pipes/StreamPipeSink.cs | 18 ++++++++++++------ FFMpegCore/FFMpeg/Pipes/StreamPipeSource.cs | 2 +- FFMpegCore/FFMpegCore.csproj | 10 +++++----- FFMpegCore/FFProbe/FFProbe.cs | 2 +- 12 files changed, 28 insertions(+), 22 deletions(-) diff --git a/FFMpegCore.Test/FFMpegCore.Test.csproj b/FFMpegCore.Test/FFMpegCore.Test.csproj index 971b098..59f2645 100644 --- a/FFMpegCore.Test/FFMpegCore.Test.csproj +++ b/FFMpegCore.Test/FFMpegCore.Test.csproj @@ -36,8 +36,8 @@ - - + + diff --git a/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs index 17d0372..adc25fb 100644 --- a/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs @@ -24,7 +24,7 @@ protected override async Task ProcessDataAsync(CancellationToken token) await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false); if (!Pipe.IsConnected) throw new TaskCanceledException(); - await Writer.CopyAsync(Pipe, token).ConfigureAwait(false); + await Writer.WriteAsync(Pipe, token).ConfigureAwait(false); } } } diff --git a/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs index ebf1e7f..f089a1e 100644 --- a/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs @@ -21,7 +21,7 @@ protected override async Task ProcessDataAsync(CancellationToken token) await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false); if (!Pipe.IsConnected) throw new TaskCanceledException(); - await Reader.CopyAsync(Pipe, token).ConfigureAwait(false); + await Reader.ReadAsync(Pipe, token).ConfigureAwait(false); } } } diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index 92fa6fe..8a30dfc 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -98,7 +98,7 @@ public async Task ProcessAsynchronously(bool throwOnError = true) void OnCancelEvent(object sender, EventArgs args) { - instance?.SendInput("q"); + instance.SendInput("q"); cancellationTokenSource.Cancel(); instance.Started = false; } diff --git a/FFMpegCore/FFMpeg/FFMpegOptions.cs b/FFMpegCore/FFMpeg/FFMpegOptions.cs index 8a98a0a..947f942 100644 --- a/FFMpegCore/FFMpeg/FFMpegOptions.cs +++ b/FFMpegCore/FFMpeg/FFMpegOptions.cs @@ -32,7 +32,7 @@ static FFMpegOptions() { if (File.Exists(ConfigFile)) { - Options = JsonSerializer.Deserialize(File.ReadAllText(ConfigFile)); + Options = JsonSerializer.Deserialize(File.ReadAllText(ConfigFile))!; foreach (var pair in DefaultExtensionsOverrides) if (!Options.ExtensionOverrides.ContainsKey(pair.Key)) Options.ExtensionOverrides.Add(pair.Key, pair.Value); } diff --git a/FFMpegCore/FFMpeg/Pipes/IPipeSink.cs b/FFMpegCore/FFMpeg/Pipes/IPipeSink.cs index 8010d87..875407e 100644 --- a/FFMpegCore/FFMpeg/Pipes/IPipeSink.cs +++ b/FFMpegCore/FFMpeg/Pipes/IPipeSink.cs @@ -5,7 +5,7 @@ namespace FFMpegCore.Pipes { public interface IPipeSink { - Task CopyAsync(System.IO.Stream inputStream, CancellationToken cancellationToken); + Task ReadAsync(System.IO.Stream inputStream, CancellationToken cancellationToken); string GetFormat(); } } diff --git a/FFMpegCore/FFMpeg/Pipes/IPipeSource.cs b/FFMpegCore/FFMpeg/Pipes/IPipeSource.cs index 35766d0..55fdcc3 100644 --- a/FFMpegCore/FFMpeg/Pipes/IPipeSource.cs +++ b/FFMpegCore/FFMpeg/Pipes/IPipeSource.cs @@ -9,6 +9,6 @@ namespace FFMpegCore.Pipes public interface IPipeSource { string GetFormat(); - Task CopyAsync(System.IO.Stream outputStream, CancellationToken cancellationToken); + Task WriteAsync(System.IO.Stream outputStream, CancellationToken cancellationToken); } } diff --git a/FFMpegCore/FFMpeg/Pipes/RawVideoPipeSource.cs b/FFMpegCore/FFMpeg/Pipes/RawVideoPipeSource.cs index 8739a40..eef4343 100644 --- a/FFMpegCore/FFMpeg/Pipes/RawVideoPipeSource.cs +++ b/FFMpegCore/FFMpeg/Pipes/RawVideoPipeSource.cs @@ -45,7 +45,7 @@ public string GetFormat() return $"-f rawvideo -r {FrameRate} -pix_fmt {StreamFormat} -s {Width}x{Height}"; } - public async Task CopyAsync(System.IO.Stream outputStream, CancellationToken cancellationToken) + public async Task WriteAsync(System.IO.Stream outputStream, CancellationToken cancellationToken) { if (_framesEnumerator.Current != null) { diff --git a/FFMpegCore/FFMpeg/Pipes/StreamPipeSink.cs b/FFMpegCore/FFMpeg/Pipes/StreamPipeSink.cs index ca2246f..cd13f40 100644 --- a/FFMpegCore/FFMpeg/Pipes/StreamPipeSink.cs +++ b/FFMpegCore/FFMpeg/Pipes/StreamPipeSink.cs @@ -1,21 +1,27 @@ -using System.Threading; +using System; +using System.IO; +using System.Threading; using System.Threading.Tasks; namespace FFMpegCore.Pipes { public class StreamPipeSink : IPipeSink { - public System.IO.Stream Destination { get; } + public Func Writer { get; } public int BlockSize { get; set; } = 4096; public string Format { get; set; } = string.Empty; - public StreamPipeSink(System.IO.Stream destination) + public StreamPipeSink(Func writer) { - Destination = destination; + Writer = writer; + } + public StreamPipeSink(Stream destination) + { + Writer = (inputStream, cancellationToken) => inputStream.CopyToAsync(destination, BlockSize, cancellationToken); } - public Task CopyAsync(System.IO.Stream inputStream, CancellationToken cancellationToken) => - inputStream.CopyToAsync(Destination, BlockSize, cancellationToken); + public Task ReadAsync(System.IO.Stream inputStream, CancellationToken cancellationToken) + => Writer(inputStream, cancellationToken); public string GetFormat() => Format; } diff --git a/FFMpegCore/FFMpeg/Pipes/StreamPipeSource.cs b/FFMpegCore/FFMpeg/Pipes/StreamPipeSource.cs index db41eb7..b364037 100644 --- a/FFMpegCore/FFMpeg/Pipes/StreamPipeSource.cs +++ b/FFMpegCore/FFMpeg/Pipes/StreamPipeSource.cs @@ -17,7 +17,7 @@ public StreamPipeSource(System.IO.Stream source) Source = source; } - public Task CopyAsync(System.IO.Stream outputStream, CancellationToken cancellationToken) => Source.CopyToAsync(outputStream, BlockSize, cancellationToken); + public Task WriteAsync(System.IO.Stream outputStream, CancellationToken cancellationToken) => Source.CopyToAsync(outputStream, BlockSize, cancellationToken); public string GetFormat() => StreamFormat; } diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj index 057f605..27a80ff 100644 --- a/FFMpegCore/FFMpegCore.csproj +++ b/FFMpegCore/FFMpegCore.csproj @@ -9,10 +9,10 @@ 3.0.0.0 3.0.0.0 3.0.0.0 - - Fix hanging pipes on unix sockets -- Internal API cleanup + - Updated dependencies +- Additional StreamPipeSink constructor 8 - 3.1.0 + 3.2.0 Malte Rosenbjerg, Vlad Jerca ffmpeg ffprobe convert video audio mediafile resize analyze muxing GitHub @@ -29,8 +29,8 @@ - - + + diff --git a/FFMpegCore/FFProbe/FFProbe.cs b/FFMpegCore/FFProbe/FFProbe.cs index f650371..5b7a1e4 100644 --- a/FFMpegCore/FFProbe/FFProbe.cs +++ b/FFMpegCore/FFProbe/FFProbe.cs @@ -98,7 +98,7 @@ private static IMediaAnalysis ParseOutput(string filePath, Instance instance) var ffprobeAnalysis = JsonSerializer.Deserialize(json, new JsonSerializerOptions { PropertyNameCaseInsensitive = true - }); + })!; return new MediaAnalysis(filePath, ffprobeAnalysis); } From 96e0a036301642187144335f900e67b9090c1b51 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Wed, 25 Nov 2020 16:18:39 +0100 Subject: [PATCH 5/5] Add license expression --- FFMpegCore/FFMpegCore.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj index 27a80ff..54afd94 100644 --- a/FFMpegCore/FFMpegCore.csproj +++ b/FFMpegCore/FFMpegCore.csproj @@ -13,6 +13,7 @@ - Additional StreamPipeSink constructor 8 3.2.0 + MIT Malte Rosenbjerg, Vlad Jerca ffmpeg ffprobe convert video audio mediafile resize analyze muxing GitHub