title: How do you generate a looping animated gif for Facebook with ffmpeg
body: <p>When I paste a giphy url (<a href="https://giphy.com/gifs/good-success-ron-swanson-26gsobowozGM9umBi" rel="nofollow noreferrer">like this one</a>) into a facebook post or comment, the gif plays immediately and loops indefinitely. When I upload ones I make from <a href="https://www.ffmpeg.org" rel="nofollow noreferrer">ffmpeg</a>, neither of those things happen. You have to click a play button to start the animation and then it ends after one time through. </p>
  
  <p>I have a couple of ffmpeg commands I use to create the gifs. They are: </p>
  
  <pre><code>ffmpeg -ss 10 -t 5  -i input.m4v -vf "fps=15,scale=800:-2:flags=lanczos,palettegen" -y palette.png
  </code></pre>
  
  <p>and </p>
  
  <pre><code>ffmpeg -ss 10.6 -t 5 -i input.m4v -i palette.png -filter_complex "fps=15,scale=800:-1:lanczos[video];[video][1:v]paletteuse" output.gif
  </code></pre>
  
  <p>The first one generates a custom color pallet that's used by the second one to create a high quality animated gif. I've also tried adding <code>-loop 0</code> (i.e. <code>ffmpeg -ss 10.6 -t 5 -i input.m4v -i palette.png -filter_complex "fps=15,scale=800:-1:lanczos[video];[video][1:v]paletteuse" -loop 0 output.gif</code>) but that didn't work either. </p>
  
  <p>I also tried uploading the ffmpeg generated images to a personal website and calling them from there but those didn't load at all. </p>
  
  <p>In case it helps, here's a copy of one of the gifs (which autostarts and loops on StackOverflow for me but not on FB)</p>
  
  <p><a href="https://i.stack.imgur.com/TyTSI.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TyTSI.gif" alt="enter image description here"></a></p>
  
  <p><strong>How does one go about creating a gif that will autostart and loop indefinitely for facebook?</strong></p>
  
  <p>(Note: I've got no problem if I need to do something with a personal website, but I don't want to use Giphly or the other animated gif sites directly if at all possible. Also worth pointing out that I discovered if I download the image from giphly and upload it, it doesn't autostart either. So, this may be something internal to FB, but I'd still like to figure that out.)</p>