--- url: "https://web.dev/articles/codelab-replace-gifs-with-video" titulek: "Replace GIFs with video | Articles | web.dev" h1: "Replace GIFs with video Stay organized with collections Save and categorize content based on your preferences." popis: "In this codelab, learn how to improve performance by replacing an animated GIF with a video." jazyk: "en" kanonicka: "https://web.dev/articles/codelab-replace-gifs-with-video" drobecky: ["Articles", "Replace GIFs with video"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 22:29:29" znaku: 4660 slov: 755 kodovani: "iso-8859-2" sha256: "6d1da19b3318c1d346306900b44a5b373b8dc223990b4a9b3a96b7a91da3f892" --- Replace GIFs with video Stay organized with collections Save and categorize content based on your preferences. Rob Dodson In this codelab, improve performance by replacing an animated GIF with a video. Measure first First measure how the website performs: To preview the site, press **View App**. Then press **Fullscreen** . Press `Control+Shift+J` (or `Command+Option+J` on Mac) to open DevTools. Click the **Lighthouse** tab. Make sure the **Performance** checkbox is selected in the *Categories* list. Click the **Generate report** button. When you're finished, you should see that Lighthouse has flagged the GIF as an issue in its "Use video formats for animated content" audit. Get FFmpeg There are a number of ways you can convert GIFs to video; this guide uses **[FFmpeg](https://www.ffmpeg.org/)**. It's already installed in the Glitch VM, and, if you want, you can follow [these instructions to install it on your local machine](/articles/replace-gifs-with-videos#create_mpeg_videos) as well. Open the console Double-check that FFmpeg is installed and working: Click **Remix to Edit** to make the project editable. Click **Terminal** (note: if the Terminal button does not show you may need to use the Fullscreen option). In the console, run: `which ffmpeg` You should get a file path back: `/usr/bin/ffmpeg` Change GIF to video In the console, run `cd images` to enter the images directory. Run `ls` to see the contents. You should see something like this: `$ ls cat-herd.gif` In the console, run: `ffmpeg -i cat-herd.gif -b:v 0 -crf 25 -f mp4 -vcodec libx264 -pix_fmt yuv420p cat-herd.mp4` This tells FFmpeg to take the **input**, signified by the `-i` flag, of cat-herd.gif and convert it to a video called cat-herd.mp4. This should take a second to run. When the command finishes, you should be able to type `ls` again and see two files: `$ ls cat-herd.gif cat-herd.mp4` Create WebM videos While MP4 has been around since 1999, WebM is a relative newcomer having been initially released in 2010. WebM videos can be much smaller than MP4 videos, so it makes sense to generate both. Thankfully the `