From 157a53690f92550ef3852c73dab239a25bcc979d Mon Sep 17 00:00:00 2001 From: Thierry Fleury Date: Sun, 28 Feb 2021 19:28:35 +0100 Subject: [PATCH] Add OutputStreamArgument (cherry picked from commit 0c64c4d81d7055a582d8377123dbc3b7ba86e444) --- .../FFMpeg/Arguments/OutputStreamArgument.cs | 26 +++++++++++++++++++ FFMpegCore/FFMpeg/FFMpegArguments.cs | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 FFMpegCore/FFMpeg/Arguments/OutputStreamArgument.cs diff --git a/FFMpegCore/FFMpeg/Arguments/OutputStreamArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputStreamArgument.cs new file mode 100644 index 0000000..5581929 --- /dev/null +++ b/FFMpegCore/FFMpeg/Arguments/OutputStreamArgument.cs @@ -0,0 +1,26 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace FFMpegCore.Arguments +{ + /// + /// Represents output stream parameter + /// + public class OutputStreamArgument : IOutputArgument + { + public readonly string Stream; + + public OutputStreamArgument(string stream) + { + Stream = stream; + } + + public void Post() { } + + public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask; + + public void Pre() { } + + public string Text => Stream; + } +} diff --git a/FFMpegCore/FFMpeg/FFMpegArguments.cs b/FFMpegCore/FFMpeg/FFMpegArguments.cs index 44e20d2..d2609eb 100644 --- a/FFMpegCore/FFMpeg/FFMpegArguments.cs +++ b/FFMpegCore/FFMpeg/FFMpegArguments.cs @@ -51,6 +51,8 @@ private FFMpegArguments WithInput(IInputArgument inputArgument, Action? addArguments = null) => ToProcessor(new OutputArgument(file, overwrite), addArguments); public FFMpegArgumentProcessor OutputToFile(Uri uri, bool overwrite = true, Action? addArguments = null) => ToProcessor(new OutputArgument(uri.AbsolutePath, overwrite), addArguments); + public FFMpegArgumentProcessor OutputToStream(string uri, Action? addArguments = null) => ToProcessor(new OutputStreamArgument(uri), addArguments); + public FFMpegArgumentProcessor OutputToStream(Uri uri, Action? addArguments = null) => ToProcessor(new OutputStreamArgument(uri.ToString()), addArguments); public FFMpegArgumentProcessor OutputToPipe(IPipeSink reader, Action? addArguments = null) => ToProcessor(new OutputPipeArgument(reader), addArguments); private FFMpegArgumentProcessor ToProcessor(IOutputArgument argument, Action? addArguments)