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