Convert Y4M to GIF — Free Online Tool

Convert Y4M (YUV4MPEG2) lossless uncompressed video to animated GIF entirely in your browser. This tool encodes the raw YUV pixel data from your Y4M intermediate file into GIF's palette-based 256-color format, producing a looping animation ready for web use.

FFmpeg Command

Copy this command to run the same conversion locally with FFmpeg on your desktop. Download FFmpeg

Free — no uploads, no signups. Your files never leave your browser.

Estimated output:

Conversion Complete!

Download

How It Works

Y4M files store raw, uncompressed YUV video frames with no quality loss — they are often the output of professional encoding pipelines or tools like x264 and libvpx when piping between stages. Converting to GIF means FFmpeg reads each uncompressed frame directly (no decoding step needed since Y4M is raw) and re-encodes it using the GIF codec, which maps each frame's full-color image into an indexed 8-bit palette of up to 256 colors. This palette quantization is the most significant transformation in this conversion: the rich YUV color space is reduced to a best-fit 256-color palette per frame, which can introduce visible color banding and dithering in footage with smooth gradients. The output GIF is set to loop indefinitely via the -loop 0 flag. Because Y4M contains no audio, no audio stream is lost — GIF also carries no audio, so the two formats are aligned on that front. File size will typically increase dramatically for long clips due to GIF's inefficient LZW compression relative to modern video codecs, but for short clips this workflow produces clean, artifact-free animated GIFs since the source has zero pre-existing compression artifacts.

What Each Flag Does

Flag What it does
ffmpeg Invokes the FFmpeg command-line tool. In the browser version, this runs via FFmpeg.wasm compiled to WebAssembly, executing the same logic as the desktop binary without any server upload.
-i input.y4m Specifies the input Y4M file. FFmpeg reads the YUV4MPEG2 header to determine frame dimensions, colorspace (e.g., YUV 4:2:0), and frame rate, then streams the raw uncompressed frames directly into the encoding pipeline with no decoding overhead.
-c:v gif Selects the GIF video encoder for the output. This encoder converts each raw YUV frame from the Y4M source into an 8-bit indexed RGB frame with a per-frame palette of up to 256 colors, applying LZW compression to produce the GIF bitstream.
-loop 0 Sets the GIF's Netscape Application Extension loop count to 0, which signals to browsers and GIF viewers that the animation should loop indefinitely. Without this flag, many players will default to playing the animation only once.
output.gif Specifies the output filename and container. The .gif extension tells FFmpeg to write a Graphics Interchange Format file containing the palette-quantized, LZW-compressed animation frames generated from the Y4M source.

Common Use Cases

  • Export a short lossless Y4M clip from a professional video pipeline (e.g., an x264 or FFmpeg pipe) as an animated GIF for embedding in documentation, README files, or web articles
  • Convert a Y4M test sequence used in codec development or video quality research into a GIF for quick visual inspection without needing a specialized raw video player
  • Turn a Y4M intermediate produced by a motion graphics renderer or compositing tool into a looping GIF for use in presentations or social media
  • Create a lossless-source GIF from a Y4M file generated by screen capture tools that output raw YUV, ensuring no pre-existing codec artifacts affect the final animation
  • Generate a palette-accurate animated GIF from a Y4M clip for comparison against compressed video formats, using the uncompressed source as a quality baseline reference
  • Convert Y4M demo footage or sample sequences distributed with video processing libraries into universally viewable GIFs for sharing with non-technical stakeholders

Frequently Asked Questions

Yes — the conversion from Y4M to GIF is lossy in terms of color fidelity even though GIF itself is technically lossless within its own color model. Y4M stores full YUV color information, while GIF can only represent 256 colors per frame using an indexed palette. FFmpeg's GIF encoder will perform color quantization to find the best-fit 256-color palette for each frame, which can result in visible color banding and dithering artifacts, especially in footage with smooth gradients or photographic content. The upside is that starting from a lossless Y4M source means there are no pre-existing compression artifacts to compound this reduction.
This is actually unusual — Y4M files are typically enormous because they store raw uncompressed video, while GIF uses LZW lossless compression. For most short clips, the GIF should be significantly smaller than the Y4M source. However, if your GIF is unexpectedly large, it is likely because the content has a lot of motion or color variation, which reduces LZW's effectiveness. GIF also stores one full palette-quantized frame at a time with no inter-frame compression like modern video codecs use, so long or complex animations can still produce large files.
Yes — FFmpeg reads the frame rate metadata embedded in the Y4M file header and uses it to set the delay between GIF frames. GIF frame timing is stored in centiseconds (1/100th of a second), so there is some rounding for frame rates that do not divide evenly into centisecond intervals — for example, 30fps becomes approximately 33ms per frame (3.33 centiseconds rounded). Very high frame rates like 60fps or 120fps may be rendered less smoothly due to this timing resolution limitation in the GIF format.
The -loop 0 flag instructs FFmpeg to set the GIF's Netscape looping extension to loop indefinitely, which is the standard behavior expected for animated GIFs on the web. If you want the GIF to play only once and stop, you can change this to -loop 1. To loop a specific number of times, note that GIF loop counts are off-by-one in FFmpeg's implementation — use -loop 1 for no repeat (plays once) or -loop 2 to play twice total, and so on. Remove the flag entirely from the command to omit the loop extension, though browser behavior without the extension varies.
Yes — the single most effective improvement is to use FFmpeg's palettegen and paletteuse filters rather than the basic -c:v gif approach. This two-pass method generates an optimized global or per-frame palette from the actual content of your Y4M video: first run 'ffmpeg -i input.y4m -vf palettegen palette.png' to generate the palette, then run 'ffmpeg -i input.y4m -i palette.png -lavfi "paletteuse" -loop 0 output.gif' to apply it. This significantly reduces color banding compared to the default per-frame palette quantization, especially for content with a consistent color scheme.
The command shown converts a single file, but you can easily batch process on your desktop by wrapping it in a shell loop. On Linux or macOS, use: 'for f in *.y4m; do ffmpeg -i "$f" -c:v gif -loop 0 "${f%.y4m}.gif"; done'. On Windows PowerShell, use: 'Get-ChildItem *.y4m | ForEach-Object { ffmpeg -i $_.FullName -c:v gif -loop 0 ($_.BaseName + ".gif") }'. The browser-based tool processes one file at a time, so the desktop FFmpeg command is the recommended approach for bulk conversions or for Y4M files over 1GB.

Technical Notes

Y4M (YUV4MPEG2) is a headerized raw video format where each frame is preceded by a small ASCII header indicating frame dimensions, colorspace, and timing. FFmpeg treats it as a rawvideo stream and requires no decoding, making reads extremely fast. The critical technical constraint in this conversion is GIF's 8-bit indexed color model: the gif encoder in FFmpeg performs per-frame palette generation by default, choosing 256 colors that best represent each individual frame. This means consecutive frames may shift palette entries slightly, which can cause subtle flickering in areas of the image that happen to fall near palette boundaries between frames. Y4M files commonly use YUV 4:2:0 or 4:4:4 chroma subsampling; FFmpeg will convert the YUV colorspace to RGB internally before palette quantization since GIF operates in the RGB color space. GIF supports 1-bit transparency (a single palette index designated as transparent), but this conversion does not set a transparency index since raw Y4M video has no alpha channel. The LZW compression in GIF is most efficient on content with horizontal runs of identical color — solid backgrounds, pixel art, and simple graphics compress well, while natural footage or gradients compress poorly and produce large files. There is no metadata preservation between these formats: Y4M headers (frame rate, aspect ratio, colorspace) are consumed by FFmpeg during reading but GIF has no equivalent metadata fields, so this information is not embedded in the output file.

Related Tools