Add demux concat

Former-commit-id: 4e5d464753
This commit is contained in:
Malte Rosenbjerg 2020-06-16 07:42:35 +02:00
parent 5ee26d52ad
commit 9b7bebfd84
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents parameter of concat argument
/// Used for creating video from multiple images or videos
/// </summary>
public class DemuxConcatArgument : IInputArgument
{
public readonly IEnumerable<string> Values;
public DemuxConcatArgument(IEnumerable<string> values)
{
Values = values;
}
private readonly string _tempFileName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid() + ".txt");
public void Pre()
{
File.WriteAllLines(_tempFileName, Values);
}
public void Post()
{
File.Delete(_tempFileName);
}
public string Text => $"-f concat -safe 0 -i \"{_tempFileName}\"";
}
}

View file

@ -32,6 +32,7 @@ private FFMpegArguments(IInputArgument inputArgument)
public static FFMpegArguments FromInputFiles(params FileInfo[] files) => new FFMpegArguments(new InputArgument(false, files));
public static FFMpegArguments FromInputFiles(bool verifyExists, params FileInfo[] files) => new FFMpegArguments(new InputArgument(verifyExists, files));
public static FFMpegArguments FromConcatenation(params string[] files) => new FFMpegArguments(new ConcatArgument(files));
public static FFMpegArguments FromDemuxConcatenation(params string[] files) => new FFMpegArguments(new ConcatArgument(files));
public static FFMpegArguments FromPipe(IPipeSource writer) => new FFMpegArguments(new InputPipeArgument(writer));