0

I have a large gif file (100+ MB) and I'd like to convert it to webm to reduce the size of the final file to 10-12 MB. I'm using ffmpeg to do this and it converts the file just fine except the resulting video isn't as crisp as I'd like it to be, the 'pixel art' quality isn't preserved. So I'm wondering if there's a better codec to achieve this quality or should I be using a format other than webm?

Here is the command I am using:

ffmpeg -y -i test.gif -r 16 -c:v libvpx -quality good -cpu-used 0 -b:v 500K -crf 12 -pix_fmt yuv420p -movflags faststart test.webm

I've tried variations of this command to no avail, changing the quality, changing the chroma subsampling. I've also tried webp, which looks better, but doesn't compress the file nearly enough.

Examples of the differences:

Webm:

webm

Gif:

gif

3
  • The main issue is probably -pix_fmt yuv420p. Try -pix_fmt yuv444p instead. Don't use both -b:v 500K and -crf 12. For start, keep only the -crf 12 (tuning the bitrate may be more difficult). You may also try libx265 codec (and MKV container).
    – Rotem
    Aug 15, 2022 at 7:14
  • I've tried using -pix_fmt yuv444p and have had no luck with that. I also reran without specifying the bitrate and with different values for -crf but the individual pixels still look a bit "fuzzy". libx265 does look a lot better, its not quite up to par with the original gif but I think its acceptable.
    – Anodos
    Aug 15, 2022 at 12:11
  • Why does the Webm image is larger than the Gif image? Check your Video Player settings. Make sure the video is displayed "pixel to pixel" without scaling.
    – Rotem
    Aug 15, 2022 at 12:32

0

You must log in to answer this question.

Browse other questions tagged .