mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Cleanup
This commit is contained in:
parent
31685da18a
commit
6b1e411bfe
12 changed files with 11 additions and 15 deletions
|
@ -2,7 +2,6 @@
|
||||||
using System;
|
using System;
|
||||||
using FFMpegCore.Arguments;
|
using FFMpegCore.Arguments;
|
||||||
using FFMpegCore.Enums;
|
using FFMpegCore.Enums;
|
||||||
using FFMpegCore.Exceptions;
|
|
||||||
|
|
||||||
namespace FFMpegCore.Test
|
namespace FFMpegCore.Test
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ public ConcatArgument(IEnumerable<string> values)
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pre() { }
|
public void Pre() { }
|
||||||
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
|
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
|
||||||
public void Post() { }
|
public void Post() { }
|
||||||
|
|
||||||
public string Text => $"-i \"concat:{string.Join(@"|", Values)}\"";
|
public string Text => $"-i \"concat:{string.Join(@"|", Values)}\"";
|
||||||
|
|
|
@ -21,7 +21,7 @@ public DemuxConcatArgument(IEnumerable<string> values)
|
||||||
private readonly string _tempFileName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid() + ".txt");
|
private readonly string _tempFileName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid() + ".txt");
|
||||||
|
|
||||||
public void Pre() => File.WriteAllLines(_tempFileName, Values);
|
public void Pre() => File.WriteAllLines(_tempFileName, Values);
|
||||||
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
|
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
|
||||||
public void Post() => File.Delete(_tempFileName);
|
public void Post() => File.Delete(_tempFileName);
|
||||||
|
|
||||||
public string Text => $"-f concat -safe 0 -i \"{_tempFileName}\"";
|
public string Text => $"-f concat -safe 0 -i \"{_tempFileName}\"";
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace FFMpegCore.Arguments
|
||||||
public interface IInputOutputArgument : IArgument
|
public interface IInputOutputArgument : IArgument
|
||||||
{
|
{
|
||||||
void Pre();
|
void Pre();
|
||||||
Task During(CancellationToken? cancellationToken = null);
|
Task During(CancellationToken cancellationToken = default);
|
||||||
void Post();
|
void Post();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.IO;
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ public void Pre()
|
||||||
throw new FileNotFoundException("Input file not found", FilePath);
|
throw new FileNotFoundException("Input file not found", FilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
|
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
|
||||||
public void Post() { }
|
public void Post() { }
|
||||||
|
|
||||||
public string Text => $"-i \"{FilePath}\"";
|
public string Text => $"-i \"{FilePath}\"";
|
||||||
|
|
|
@ -19,7 +19,7 @@ public InputPipeArgument(IPipeSource writer) : base(PipeDirection.Out)
|
||||||
|
|
||||||
public override string Text => $"-y {Writer.GetFormat()} -i \"{PipePath}\"";
|
public override string Text => $"-y {Writer.GetFormat()} -i \"{PipePath}\"";
|
||||||
|
|
||||||
public override async Task ProcessDataAsync(CancellationToken token)
|
protected override async Task ProcessDataAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
|
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
|
||||||
if (!Pipe.IsConnected)
|
if (!Pipe.IsConnected)
|
||||||
|
|
|
@ -25,7 +25,7 @@ public void Pre()
|
||||||
if (!Overwrite && File.Exists(Path))
|
if (!Overwrite && File.Exists(Path))
|
||||||
throw new FFMpegException(FFMpegExceptionType.File, "Output file already exists and overwrite is disabled");
|
throw new FFMpegException(FFMpegExceptionType.File, "Output file already exists and overwrite is disabled");
|
||||||
}
|
}
|
||||||
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
|
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
|
||||||
public void Post()
|
public void Post()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public OutputPipeArgument(IPipeSink reader) : base(PipeDirection.In)
|
||||||
|
|
||||||
public override string Text => $"\"{PipePath}\" -y";
|
public override string Text => $"\"{PipePath}\" -y";
|
||||||
|
|
||||||
public override async Task ProcessDataAsync(CancellationToken token)
|
protected override async Task ProcessDataAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
|
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
|
||||||
if (!Pipe.IsConnected)
|
if (!Pipe.IsConnected)
|
||||||
|
|
|
@ -34,7 +34,7 @@ public void Post()
|
||||||
Pipe = null!;
|
Pipe = null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task During(CancellationToken? cancellationToken = null)
|
public async Task During(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public async Task During(CancellationToken? cancellationToken = null)
|
||||||
Post();
|
Post();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Task ProcessDataAsync(CancellationToken token);
|
protected abstract Task ProcessDataAsync(CancellationToken token);
|
||||||
public abstract string Text { get; }
|
public abstract string Text { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ internal void Pre()
|
||||||
foreach (var argument in Arguments.OfType<IInputOutputArgument>())
|
foreach (var argument in Arguments.OfType<IInputOutputArgument>())
|
||||||
argument.Pre();
|
argument.Pre();
|
||||||
}
|
}
|
||||||
internal async Task During(CancellationToken? cancellationToken = null)
|
internal async Task During(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var inputOutputArguments = Arguments.OfType<IInputOutputArgument>();
|
var inputOutputArguments = Arguments.OfType<IInputOutputArgument>();
|
||||||
await Task.WhenAll(inputOutputArguments.Select(io => io.During(cancellationToken))).ConfigureAwait(false);
|
await Task.WhenAll(inputOutputArguments.Select(io => io.During(cancellationToken))).ConfigureAwait(false);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace FFMpegCore.Pipes
|
namespace FFMpegCore.Pipes
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace FFMpegCore
|
namespace FFMpegCore
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue