How to update GIF to always loop infinitely using Transloadit

159 Views Asked by At

From my understanding, the gif loop count is dependent on the gif file itself, so I'm trying to figure out a C# way to always update a gif's loop count to ensure it always loops infinitely.

I've been trying to do this with Transloadit, but I haven't been able to adjust the loop count at all. I've tried setting it to infinite as well as a specific amount, like loop twice, just to see if I could change it but it always keeps the gif's original loop count.

Some things I've tried are:

  • Using image/resize robot and adding ImageMagick params for setting a loop count
  • Using video/encode robot with ffmpeg params for setting a loop count
  • Using image/resize robot to convert the gif into a gif (with and without ImageMagick params)

I know it's possible to adjust this directly with ImageMagick and ffmpeg but need to use Transloadit, as that's how we're managing S3 uploading. In case it helps, because we're using S3, I'm always referencing the import when trying these conversions.

Here's an example attempt of mine.

_steps.encode = new
{
  use = "import",
  result = true,
  robot = "/video/encode",
  ffmpeg_stack = "v3.3.3",
  ffmpeg = new
  {
    f = "gif",
    loop = 0
  }
};

Hoping there's some Transloadit flag or pattern that I'm not aware of...

1

There are 1 best solutions below

0
Jessie On

TIL ffmpeg updated its loop keys, so though the documentation says to use -1 for infinite loop, my version worked with 0. So my example above ended up being the answer, I definitely tried it before but one last try ended up doing the trick lol ️