Labsco
microsoft logo

video-to-gif

✓ Official1,200

by microsoft · part of microsoft/hve-core

Video-to-GIF conversion skill with FFmpeg two-pass optimization - Brought to you by microsoft/hve-core

🔥🔥🔥✓ VerifiedFreeQuick setup
🧩 One of 7 skills in the microsoft/hve-core package — works on its own, and pairs well with its siblings.

This is the playbook your agent receives when the skill activates — you don't need to read it to use the skill, but it's here to audit before installing.


name: video-to-gif description: 'Video-to-GIF conversion with FFmpeg two-pass optimization' license: MIT compatibility: 'Requires FFmpeg on PATH' metadata: authors: "microsoft/hve-core" spec_version: "1.0" last_updated: "2026-03-18"

Video-to-GIF Conversion Skill

This skill converts video files to optimized GIF animations using FFmpeg two-pass palette optimization.

Overview

The two-pass conversion process generates superior quality GIFs compared to single-pass approaches. Pass one analyzes the video and creates an optimized color palette. Pass two applies that palette to produce the final GIF with better color fidelity and smaller file sizes.

Response Format

After successful conversion, include a file link to the GIF in the response with the absolute file path:

/absolute/path/to/filename.gif

This allows the user to open the file and review it.

Parameters Reference

ParameterFlag (bash)Flag (PowerShell)DefaultDescription
Input file--input-InputPath(required)Source video file path
Output file--output-OutputPathinput.gifDestination GIF file path
Frame rate--fps-Fps10Frames per second
Width--width-Width1280Output width in pixels
Dithering--dither-Dithersierra2_4aDithering algorithm
Tonemapping--tonemap-TonemaphableHDR tonemapping algorithm
Skip palette--skip-palette-SkipPalettefalseUse single-pass mode
Start time--start-Start0Start time in seconds
Duration--duration-Duration(full video)Duration to convert in seconds
Loop count--loop-Loop0GIF loop count (0 = infinite)

Frame Rate (FPS)

FPS controls animation smoothness and file size. Lower values reduce file size but create choppier motion.

FPSUse Case
5Simple animations, icons
10General use (default)
15Smooth motion, UI demos
24Near-video quality

Width

Width sets the output horizontal resolution in pixels. Height scales proportionally to maintain aspect ratio.

WidthUse Case
320Thumbnails, previews
640Documentation
800Presentations
1280High detail (default)

Dithering Algorithms

Dithering determines how the 256-color GIF palette approximates the original colors.

AlgorithmQualitySpeedBest For
sierra2_4aHighMediumGeneral use (default)
floyd_steinbergHighSlowPhotographic content
bayerMediumFastGraphics with solid colors
noneLowFastestStylized/posterized look

Time Range Selection

Use --start and --duration to convert a specific portion of the video:

# Start at 5 seconds, convert 10 seconds
scripts/convert.sh --input video.mp4 --start 5 --duration 10

Loop Control

Use --loop to control GIF repeat behavior:

ValueBehavior
0Loop forever
1Play once
NPlay N times

Two-Pass vs Single-Pass

Two-Pass (Default)

Two-pass conversion creates a custom palette from the source video, then applies it:

# Pass 1: Generate palette
ffmpeg -i input.mp4 \
  -vf "fps=10,scale=1280:-1:flags=lanczos,palettegen=stats_mode=diff" \
  -y /tmp/palette.png

# Pass 2: Create GIF
ffmpeg -i input.mp4 -i /tmp/palette.png \
  -filter_complex "fps=10,scale=1280:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=sierra2_4a:diff_mode=rectangle" \
  -loop 0 -y output.gif

Two-pass produces better color accuracy and typically smaller files.

Single-Pass

Single-pass skips palette generation and uses FFmpeg's default 256-color palette:

ffmpeg -i input.mp4 \
  -vf "fps=10,scale=1280:-1:flags=lanczos" \
  -loop 0 -y output.gif

Single-pass processes faster but produces lower quality output with potential color banding.

Use single-pass via --skip-palette (bash) or -SkipPalette (PowerShell).

Script Reference

convert.sh (Bash)

# Basic usage
scripts/convert.sh video.mp4

# Custom output path
scripts/convert.sh --input video.mp4 --output demo.gif

# Adjust quality parameters
scripts/convert.sh --input video.mp4 --fps 15 --width 640 --dither floyd_steinberg

# HDR video with custom tonemapping
scripts/convert.sh --input hdr-video.mov --tonemap reinhard

# Extract a 10-second clip starting at 5 seconds
scripts/convert.sh --input video.mp4 --start 5 --duration 10

# Create a GIF that plays only once
scripts/convert.sh --input video.mp4 --loop 1

# Fast single-pass mode
scripts/convert.sh --input video.mp4 --skip-palette

convert.ps1 (PowerShell)

# Basic usage
scripts/convert.ps1 -InputPath video.mp4

# Custom output path
scripts/convert.ps1 -InputPath video.mp4 -OutputPath demo.gif

# Adjust quality parameters
scripts/convert.ps1 -InputPath video.mp4 -Fps 15 -Width 640 -Dither floyd_steinberg

# HDR video with custom tonemapping
scripts/convert.ps1 -InputPath hdr-video.mov -Tonemap reinhard

# Extract a 10-second clip starting at 5 seconds
scripts/convert.ps1 -InputPath video.mp4 -Start 5 -Duration 10

# Create a GIF that plays only once
scripts/convert.ps1 -InputPath video.mp4 -Loop 1

# Fast single-pass mode
scripts/convert.ps1 -InputPath video.mp4 -SkipPalette

Examples

HDR Video Conversion

HDR content is detected automatically. No special flags are needed:

scripts/convert.sh hdr-footage.mov

The script applies hable tonemapping by default. Use --tonemap to try different algorithms:

# Use reinhard for more saturated colors
scripts/convert.sh --input hdr-footage.mov --tonemap reinhard

Time Range Extraction

Extract a specific segment from a longer video:

# Convert seconds 30-45 of a screencast
scripts/convert.sh --input screencast.mp4 --start 30 --duration 15 --fps 15

Documentation Thumbnails

Create compact thumbnails for documentation:

scripts/convert.sh --input demo.mp4 --width 320 --fps 8