From 4dbbf345d4912283dc63a92d71d7400b4501783c Mon Sep 17 00:00:00 2001 From: Rafael Carvalho Date: Mon, 6 Mar 2023 17:25:08 +1300 Subject: [PATCH] Add "GifPalettArgument" for outputting GIFs --- .../FFMpeg/Arguments/GifPalettArgument.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 FFMpegCore/FFMpeg/Arguments/GifPalettArgument.cs diff --git a/FFMpegCore/FFMpeg/Arguments/GifPalettArgument.cs b/FFMpegCore/FFMpeg/Arguments/GifPalettArgument.cs new file mode 100644 index 0000000..408832d --- /dev/null +++ b/FFMpegCore/FFMpeg/Arguments/GifPalettArgument.cs @@ -0,0 +1,21 @@ +using System.Drawing; + +namespace FFMpegCore.Arguments +{ + public class GifPalettArgument : IArgument + { + private readonly int _fps; + + private readonly Size? _size; + + public GifPalettArgument(int fps, Size? size) + { + _fps = fps; + _size = size; + } + + private string ScaleText => _size.HasValue ? $"scale=w={_size.Value.Width}:h={_size.Value.Height}," : string.Empty; + + public string Text => $"-filter_complex \"[0:v] fps={_fps},{ScaleText}split [a][b];[a] palettegen=max_colors=32 [p];[b][p] paletteuse=dither=bayer\""; + } +}