1
votes

When I paste a giphy url (like this one) into a facebook post or comment, the gif plays immediately and loops indefinitely. When I upload ones I make from ffmpeg, neither of those things happen. You have to click a play button to start the animation and then it ends after one time through.

I have a couple of ffmpeg commands I use to create the gifs. They are:

ffmpeg -ss 10 -t 5  -i input.m4v -vf "fps=15,scale=800:-2:flags=lanczos,palettegen" -y palette.png

and

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

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 -loop 0 (i.e. 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) but that didn't work either.

I also tried uploading the ffmpeg generated images to a personal website and calling them from there but those didn't load at all.

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)

enter image description here

How does one go about creating a gif that will autostart and loop indefinitely for facebook?

(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.)

1
Can you provide a GIF that works on FB? I don't have an account so I can't try it myself. - llogan
@llogan, sure thing. I just added a link to the giphly image that works via the URL. Something I just realized is that if you pull that gif and upload it, it doesn't autostart either. So, maybe it's not the gif, but the service. I still don't understand why an image linked from another site won't work. Maybe there's something on FB that only lets it work from there... - Alan W. Smith
I suspect that Facebook knows what Giphy and Imgur are and are treating them special. I say this because I don't see anything special over on the debugger. developers.facebook.com/tools/debug/… - Brad

1 Answers

0
votes

The file from Giphy appears to be a WebP, not a GIF:

ffmpeg -i giphy
[…]
Stream #0:0: Video: webp, none, 25 tbr, 25 tbn, 25 tbc

Firefox and mediainfo concur.

So try making a WebP instead:

ffmpeg -ss 10.6 -t 5 -i input.m4v -loop 0 output.webp
  • Your ffmpeg will have to be compiled with --enable-libwebp.
  • See ffmpeg -h encoder=libwebp and ffmpeg -h muxer=webp for more options.