mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-01-18 12:36:44 +00:00
Merge 36d778a3a2
into 6836b143c7
This commit is contained in:
commit
16728ae521
2 changed files with 48 additions and 0 deletions
46
FFMpegCore/FFMpeg/Arguments/InputExistingPipeArgument.cs
Normal file
46
FFMpegCore/FFMpeg/Arguments/InputExistingPipeArgument.cs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
using System.Diagnostics;
|
||||||
|
using FFMpegCore.Pipes;
|
||||||
|
|
||||||
|
namespace FFMpegCore.Arguments
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents input parameter for a specific name pipe
|
||||||
|
/// </summary>
|
||||||
|
public class InputExistingPipeArgument : IInputArgument
|
||||||
|
{
|
||||||
|
public string PipeName { get; }
|
||||||
|
public string PipePath => PipeHelpers.GetPipePath(PipeName);
|
||||||
|
public string Text => $"-i \"{PipePath}\"";
|
||||||
|
|
||||||
|
public InputExistingPipeArgument(string pipeName)
|
||||||
|
{
|
||||||
|
PipeName = pipeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Pre()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(PipeName))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Pipe name cannot be null or empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task During(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
cancellationToken.Register(() => tcs.TrySetCanceled());
|
||||||
|
await tcs.Task;
|
||||||
|
}
|
||||||
|
catch(OperationCanceledException)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"{GetType().Name} cancelled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Post()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ private string GetText()
|
||||||
public static FFMpegArguments FromUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
public static FFMpegArguments FromUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
||||||
public static FFMpegArguments FromDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputDeviceArgument(device), addArguments);
|
public static FFMpegArguments FromDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputDeviceArgument(device), addArguments);
|
||||||
public static FFMpegArguments FromPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputPipeArgument(sourcePipe), addArguments);
|
public static FFMpegArguments FromPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputPipeArgument(sourcePipe), addArguments);
|
||||||
|
public static FFMpegArguments FromPipeInput(string pipeName, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputExistingPipeArgument(pipeName), addArguments);
|
||||||
|
|
||||||
public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configureOptions)
|
public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configureOptions)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +42,7 @@ public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configure
|
||||||
public FFMpegArguments AddUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
public FFMpegArguments AddUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
|
||||||
public FFMpegArguments AddDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputDeviceArgument(device), addArguments);
|
public FFMpegArguments AddDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputDeviceArgument(device), addArguments);
|
||||||
public FFMpegArguments AddPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputPipeArgument(sourcePipe), addArguments);
|
public FFMpegArguments AddPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputPipeArgument(sourcePipe), addArguments);
|
||||||
|
public FFMpegArguments AddPipeInput(string pipeName, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputExistingPipeArgument(pipeName), addArguments);
|
||||||
public FFMpegArguments AddMetaData(string content, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(content), addArguments);
|
public FFMpegArguments AddMetaData(string content, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(content), addArguments);
|
||||||
public FFMpegArguments AddMetaData(IReadOnlyMetaData metaData, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments);
|
public FFMpegArguments AddMetaData(IReadOnlyMetaData metaData, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue