title: FFmpeg: high quality animated GIF?
body: <p>I'm generating animated a GIF from a video on my server.</p>
  
  <p>The generated GIF is not really high quality and it looks like the pixels are huge.</p>
  
  <p>Example:</p>
  
  <p><a href="https://i.stack.imgur.com/aXnUl.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/aXnUl.gif" alt="example GIF"></a></p>
  
  <p>This is how I generate the GIF:</p>
  
  <pre><code>shell_exec("/usr/bin/ffmpeg -i video.mkv -vf scale=500:-1 -t 10 -r 10 image.gif");
  </code></pre>
  
  <p>I did a search on Google and came across this:</p>
  
  <pre><code>shell_exec("/usr/bin/ffmpeg -i video.mkv -r 20 -f image2pipe -vcodec ppm - | convert -delay 5 - output.gif");
  </code></pre>
  
  <p>But the command above doesn't do anything and no <em>output.gif</em> is being generated at all.</p>
  
  <p>There are some tutorials that I came across but none of them worked for me and some of them involve using ImageMagick which I dont have access to.</p>
  
  <p>Could someone please let me know if there is a clear way to generate a high-quality GIF using FFmpeg?</p>