mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-14 01:55:45 +00:00
27 lines
782 B
C#
27 lines
782 B
C#
using System.IO.Pipes;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using FFMpegCore.Pipes;
|
|
|
|
namespace FFMpegCore.Arguments
|
|
{
|
|
public class OutputPipeArgument : PipeArgument, IOutputArgument
|
|
{
|
|
public readonly IPipeSink Reader;
|
|
|
|
public OutputPipeArgument(IPipeSink reader) : base(PipeDirection.In)
|
|
{
|
|
Reader = reader;
|
|
}
|
|
|
|
public override string Text => $"\"{PipePath}\" -y";
|
|
|
|
public 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);
|
|
}
|
|
}
|
|
}
|