mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Merge pull request #131 from rosenbjerg/master
Updated dependencies and additional StreamPipeSink constructor
Former-commit-id: 8cfc2ffda6
This commit is contained in:
commit
e4906e913f
13 changed files with 34 additions and 23 deletions
|
@ -36,8 +36,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitHubActionsTestLogger" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
|
||||
<PackageReference Include="GitHubActionsTestLogger" Version="1.1.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public async Task<bool> ProcessAsynchronously(bool throwOnError = true)
|
|||
|
||||
void OnCancelEvent(object sender, EventArgs args)
|
||||
{
|
||||
instance?.SendInput("q");
|
||||
instance.SendInput("q");
|
||||
cancellationTokenSource.Cancel();
|
||||
instance.Started = false;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ static FFMpegOptions()
|
|||
{
|
||||
if (File.Exists(ConfigFile))
|
||||
{
|
||||
Options = JsonSerializer.Deserialize<FFMpegOptions>(File.ReadAllText(ConfigFile));
|
||||
Options = JsonSerializer.Deserialize<FFMpegOptions>(File.ReadAllText(ConfigFile))!;
|
||||
foreach (var pair in DefaultExtensionsOverrides)
|
||||
if (!Options.ExtensionOverrides.ContainsKey(pair.Key)) Options.ExtensionOverrides.Add(pair.Key, pair.Value);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<Stream, CancellationToken, Task> Writer { get; }
|
||||
public int BlockSize { get; set; } = 4096;
|
||||
public string Format { get; set; } = string.Empty;
|
||||
|
||||
public StreamPipeSink(System.IO.Stream destination)
|
||||
public StreamPipeSink(Func<Stream, CancellationToken, Task> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
<Version>3.0.0.0</Version>
|
||||
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
||||
<FileVersion>3.0.0.0</FileVersion>
|
||||
<PackageReleaseNotes>- Fix hanging pipes on unix sockets
|
||||
- Internal API cleanup</PackageReleaseNotes>
|
||||
<PackageReleaseNotes>- Updated dependencies
|
||||
- Additional StreamPipeSink constructor</PackageReleaseNotes>
|
||||
<LangVersion>8</LangVersion>
|
||||
<PackageVersion>3.1.0</PackageVersion>
|
||||
<PackageVersion>3.2.0</PackageVersion>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<Authors>Malte Rosenbjerg, Vlad Jerca</Authors>
|
||||
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
||||
<RepositoryType>GitHub</RepositoryType>
|
||||
|
@ -29,8 +30,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Instances" Version="1.6.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="4.7.2" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -98,7 +98,7 @@ private static IMediaAnalysis ParseOutput(string filePath, Instance instance)
|
|||
var ffprobeAnalysis = JsonSerializer.Deserialize<FFProbeAnalysis>(json, new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
});
|
||||
})!;
|
||||
return new MediaAnalysis(filePath, ffprobeAnalysis);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# 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)
|
||||
[![GitHub](https://img.shields.io/github/license/rosenbjerg/FFMpegCore)](https://github.com/rosenbjerg/FFMpegCore/blob/master/LICENSE)
|
||||
|
||||
# Setup
|
||||
|
||||
|
@ -209,6 +212,7 @@ The root and temp directory for the ffmpeg binaries can be configured via the `f
|
|||
<a href="https://github.com/devlev"><img src="https://avatars3.githubusercontent.com/u/2109995?v=4" title="devlev" width="80" height="80"></a>
|
||||
<a href="https://github.com/tugrulelmas"><img src="https://avatars3.githubusercontent.com/u/3829187?v=4" title="tugrulelmas" width="80" height="80"></a>
|
||||
<a href="https://github.com/rosenbjerg"><img src="https://avatars3.githubusercontent.com/u/11181960?v=4" title="rosenbjerg" width="80" height="80"></a>
|
||||
<a href="https://github.com/WeihanLi"><img src="https://avatars3.githubusercontent.com/u/7604648?v=4" title="weihanli" width="80" height="80"></a>
|
||||
|
||||
### License
|
||||
|
||||
|
|
Loading…
Reference in a new issue