mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-13 01:34:14 +01:00
Add "GifSnapshot" and "GifSnapshotAsync" methods
This commit is contained in:
parent
d14ef2268f
commit
a90918eac6
1 changed files with 30 additions and 0 deletions
|
@ -57,6 +57,36 @@ public static async Task<bool> SnapshotAsync(string input, string output, Size?
|
||||||
.ProcessAsynchronously();
|
.ProcessAsynchronously();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool GifSnapshot(string input, string output, Size? size = null, TimeSpan? captureTime = null, TimeSpan? duration = null, int ? streamIndex = null)
|
||||||
|
{
|
||||||
|
if (Path.GetExtension(output)?.ToLower() != FileExtension.Gif)
|
||||||
|
{
|
||||||
|
output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output) + FileExtension.Gif);
|
||||||
|
}
|
||||||
|
|
||||||
|
var source = FFProbe.Analyse(input);
|
||||||
|
var (arguments, outputOptions) = SnapshotArgumentBuilder.BuildGifSnapshotArguments(input, source, size, captureTime, duration, streamIndex);
|
||||||
|
|
||||||
|
return arguments
|
||||||
|
.OutputToFile(output, true, outputOptions)
|
||||||
|
.ProcessSynchronously();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<bool> GifSnapshotAsync(string input, string output, Size? size = null, TimeSpan? captureTime = null, TimeSpan? duration = null, int? streamIndex = null)
|
||||||
|
{
|
||||||
|
if (Path.GetExtension(output)?.ToLower() != FileExtension.Gif)
|
||||||
|
{
|
||||||
|
output = Path.Combine(Path.GetDirectoryName(output), Path.GetFileNameWithoutExtension(output) + FileExtension.Gif);
|
||||||
|
}
|
||||||
|
|
||||||
|
var source = await FFProbe.AnalyseAsync(input).ConfigureAwait(false);
|
||||||
|
var (arguments, outputOptions) = SnapshotArgumentBuilder.BuildGifSnapshotArguments(input, source, size, captureTime, duration, streamIndex);
|
||||||
|
|
||||||
|
return await arguments
|
||||||
|
.OutputToFile(output, true, outputOptions)
|
||||||
|
.ProcessAsynchronously();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts an image sequence to a video.
|
/// Converts an image sequence to a video.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue