<p>I have a collection of seamlessly-looping GIF images that I am trying to convert to VP9(WEBM) to cut down on filesize. A majority of these GIFs convert with no problem, and the resulting WEBM files are seamless as well. However, there are some GIF images that do not seamlessly loop after being converted, almost as if some frames are cut from the output.</p>

<p>I am using the following arguments to convert the GIFs to WEBMs (note: although the CRF/bitrate are set very high, yet the resulting file sizes are still way smaller):</p>

<pre><code>ffmpeg -i in.gif -c:v libvpx-vp9 -b:v 10M -crf 0 out.webm -y
</code></pre>

<p>After some experimentation, I think the problematic GIF files are utilizing tricks to give the illusion of seamless looping, such as transparency. The following arguments fix the looping issue, but screw up the colors (in VLC it looks fine, but when Google Chrome plays the WEBM a greenish hue is visible, as if it's only displaying one of the YUV channels):</p>

<pre><code>ffmpeg -i in.gif -c:v libvpx-vp9 -b:v 10M -crf 0 -filter_complex "[0:v] scale=-1:-1:flags=lanczos,split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=000000 [p]; [b][p] paletteuse" out.webm
</code></pre>

<p>Is there a set of parameters that will convert GIF to WEBM and guarantee that the looping will remain seamless?</p>

<p><a href="https://i.sstatic.net/gfKzj.jpg" rel="nofollow noreferrer">Here</a> is an example of one of the source GIFs.</p>

CC BY-SA 4.0
2020-04-10T17:41:57.120Z
Can you provide one of these GIF files?
llogan
CC BY-SA 4.0
2020-04-10T19:31:06.597Z
@llogan [Here](https://imgur.com/a/RgXF78R) is an example. As a gif, it loops seamlessly. Using the first set of arguments, it does not. Using the third set of arguments, it does, but viewing in certain applications displays it in weird colors.
w0f
<ffmpeg>
Some GIFs do not loop properly when converted to WEBM with FFmpeg
w0f
# Some GIFs do not loop properly when converted to WEBM with FFmpeg

(Asked by: username_0 on 2020-04-10)

I have a collection of seamlessly-looping GIF images that I am trying to convert to VP9(WEBM) to cut down on filesize. A majority of these GIFs convert with no problem, and the resulting WEBM files are seamless as well. However, there are some GIF images that do not seamlessly loop after being converted, almost as if some frames are cut from the output.
I am using the following arguments to convert the GIFs to WEBMs (note: although the CRF/bitrate are set very high, yet the resulting file sizes are still way smaller):
ffmpeg -i in.gif -c:v libvpx-vp9 -b:v 10M -crf 0 out.webm -y

After some experimentation, I think the problematic GIF files are utilizing tricks to give the illusion of seamless looping, such as transparency. The following arguments fix the looping issue, but screw up the colors (in VLC it looks fine, but when Google Chrome plays the WEBM a greenish hue is visible, as if it's only displaying one of the YUV channels):
ffmpeg -i in.gif -c:v libvpx-vp9 -b:v 10M -crf 0 -filter_complex "[0:v] scale=-1:-1:flags=lanczos,split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=000000 [p]; [b][p] paletteuse" out.webm

Is there a set of parameters that will convert GIF to WEBM and guarantee that the looping will remain seamless?
Here is an example of one of the source GIFs.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Can you provide one of these GIF files?  
> **username_0**: @username_1 [Here](https://imgur.com/a/RgXF78R) is an example. As a gif, it loops seamlessly. Using the first set of arguments, it does not. Using the third set of arguments, it does, but viewing in certain applications displays it in weird colors.  

---

## 0 answers

