mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
parent
96af90ba7e
commit
a88010d7a1
3 changed files with 13 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -7,22 +8,24 @@ namespace FFMpegCore.Arguments
|
|||
{
|
||||
public class SeekedFileInputArgument : IInputArgument
|
||||
{
|
||||
public readonly string FilePath;
|
||||
public readonly TimeSpan StartTime;
|
||||
public readonly (string FilePath, TimeSpan StartTime)[] SeekedFiles;
|
||||
|
||||
public SeekedFileInputArgument(string filePath, TimeSpan startTime)
|
||||
public SeekedFileInputArgument((string file, TimeSpan startTime)[] seekedFiles)
|
||||
{
|
||||
FilePath = filePath;
|
||||
StartTime = startTime;
|
||||
SeekedFiles = seekedFiles;
|
||||
}
|
||||
|
||||
public void Pre()
|
||||
{
|
||||
if (!File.Exists(FilePath))
|
||||
throw new FileNotFoundException("Input file not found", FilePath);
|
||||
foreach (var (seekedFile, _) in SeekedFiles)
|
||||
{
|
||||
if (!File.Exists(seekedFile))
|
||||
throw new FileNotFoundException("Input file not found", seekedFile);
|
||||
}
|
||||
}
|
||||
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
|
||||
public void Post() { }
|
||||
|
||||
public string Text => $"-ss {StartTime} -i \"{FilePath}\"";
|
||||
public string Text => string.Join(" ", SeekedFiles.Select(seekedFile => $"-ss {seekedFile.StartTime} -i \"{seekedFile.FilePath}\""));
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ public static bool Snapshot(MediaAnalysis source, string output, Size? size = nu
|
|||
size = PrepareSnapshotSize(source, size);
|
||||
|
||||
return FFMpegArguments
|
||||
.FromSeekedFile(source.Path, captureTime ?? TimeSpan.Zero)
|
||||
.FromSeekedFiles((source.Path, captureTime ?? TimeSpan.Zero))
|
||||
.WithVideoCodec(VideoCodec.Png)
|
||||
.WithFrameOutputCount(1)
|
||||
.Resize(size)
|
||||
|
|
|
@ -25,7 +25,7 @@ private FFMpegArguments(IInputArgument inputArgument)
|
|||
|
||||
public string Text => string.Join(" ", _arguments.Select(arg => arg.Text));
|
||||
|
||||
public static FFMpegArguments FromSeekedFile(string file, TimeSpan startTime) => new FFMpegArguments(new SeekedFileInputArgument(file, startTime));
|
||||
public static FFMpegArguments FromSeekedFiles(params (string file, TimeSpan startTime)[] seekedFiles) => new FFMpegArguments(new SeekedFileInputArgument(seekedFiles));
|
||||
public static FFMpegArguments FromInputFiles(params string[] files) => new FFMpegArguments(new InputArgument(true, files));
|
||||
public static FFMpegArguments FromInputFiles(bool verifyExists, params string[] files) => new FFMpegArguments(new InputArgument(verifyExists, files));
|
||||
public static FFMpegArguments FromInputFiles(params Uri[] uris) => new FFMpegArguments(new InputArgument(false, uris));
|
||||
|
|
Loading…
Reference in a new issue