Resulting GIF has wrong frame rate
static void ConvertMp4ToGif(string input, string output) { try { using (var collection = new MagickImageCollection(input)) { // collection.Coalesce(); // collection.Optimize(); collection.Write(output); } Console.WriteLine("Conversion successful. GIF file saved at: " + output); } catch (MagickException ex) { Console.WriteLine("Error during conversion: " + ex.Message); } }
Using FFMPEG
ffmpeg -y -i input.mp4 \ -vf "fps=30,scale=iw*1:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ -loop 0 output.gif
ffmpeg -i input.mp4 \ -vf "fps=30,scale=iw*0.7:-1:flags=lanczos,eq=brightness=0.09:contrast=1.18,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ -loop 0 output2.gif
ffmpeg -i intro.gif -ignore_loop 0 -i output.gif -filter_complex "[0:v]fps=10,split=2[intro1][intro2];[intro1]trim=duration=2[intro_trimmed];[intro_trimmed][intro2]concat=n=2:v=1:a=0[outv]" -map "[outv]" output_with_intro.gif
ffmpeg -y -i input.mp4 \ -vf "fps=30,scale=iw*1:-1:flags=lanczos, split[s0][s1]; [s0]palettegen[p]; [s1][p]paletteuse, drawtext=text='Your Text Here':fontfile=/Users/matt/Library/Fonts/Inter-Bold.otf:fontcolor=white:box=1:boxcolor=black:boxborderw=5:x=(W-text_w-10):y=(H-text_h-10):fontsize=50:box=1:boxborderw=20:boxcolor=black" \ -loop 0 output.gif
ffmpeg -y -i input.mp4 -vf "fps=30,scale=1280:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=256:stats_mode=diff[p];[s1][p]paletteuse=dither=none:new=1" -loop 0 output.gif