mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-12-15 18:45:44 +00:00
29 lines
1,018 B
C#
29 lines
1,018 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
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.Select(value => $"file '{value}'");
|
|
}
|
|
private readonly string _tempFileName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid() + ".txt");
|
|
|
|
public void Pre() => File.WriteAllLines(_tempFileName, Values);
|
|
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
|
|
public void Post() => File.Delete(_tempFileName);
|
|
|
|
public string Text => $"-f concat -safe 0 -i \"{_tempFileName}\"";
|
|
}
|
|
}
|