Video To Gif
MicrosoftOfficialPublished by Microsoft
- Skill
- Tool integration
- Automation and integrations
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides bash and PowerShell scripts to convert video files into GIF animations. It utilizes FFmpeg to perform a two-pass conversion process, where the first pass generates an optimized color palette and the second pass applies it to the output. The tool includes automatic HDR detection and tonemapping, as well as configurable parameters for frame rate, resolution, dithering, and time-range extraction.
What it does
- Converts video files to GIF format using two-pass palette optimization.
- Automatically detects HDR content and applies tonemapping for SDR output.
- Supports custom frame rates, output widths, and loop counts.
- Allows extraction of specific video segments using start time and duration parameters.
- Provides multiple dithering algorithms to manage color approximation.
- Includes cross-platform support via bash and PowerShell scripts.
When to use it
- When you need to convert video clips into GIF animations for documentation or presentations.
- When you require specific control over GIF resolution, frame rate, or color dithering.
- When processing HDR video content that requires tonemapping for standard GIF output.
- When you need to extract and convert only a specific portion of a longer video file.
Advantages
- Two-pass conversion process for palette optimization.
- Automatic HDR detection and tonemapping support.
- Flexible configuration for file size and visual output settings.
- Supports both bash and PowerShell environments.
- Includes built-in search logic for locating input files.
Usage examples
- “Convert my video file demo.mp4 into a GIF.”
- The script processes the video using default settings (10 FPS, 1280px width) and saves the result as demo.gif.
- “Create a GIF from the first 10 seconds of my video starting at the 5-second mark.”
- The script extracts the specified segment and generates a GIF based on the provided start and duration parameters.
- “Convert this HDR video to a GIF using the reinhard tonemapping algorithm.”
- The script detects the HDR content and applies the reinhard tonemapping algorithm to ensure proper color conversion.
- “Generate a thumbnail-sized GIF from my video.”
- The script uses the width parameter to scale the output to 320 pixels while maintaining the aspect ratio.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/video-to-gif/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip video-to-gif.zip -d .agents/skills
Documentation by Microsoft
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.gifThis allows the user to open the file and review it.
Prerequisites
FFmpeg is required and must be available in your system PATH.
macOS
brew install ffmpegLinux (Debian/Ubuntu)
sudo apt update && sudo apt install ffmpegWindows
Using Chocolatey:
choco install ffmpegUsing winget:
winget install FFmpeg.FFmpegVerify installation:
ffmpeg -versionQuick Start
Convert a video using default settings (10 FPS, 1280px width, sierra2_4a dithering):
scripts/convert.sh input.mp4scripts/convert.ps1 -InputPath input.mp4Output saves to input.gif by default.
File Search Behavior
When a filename is provided without a full path, the script searches in this order:
Current working directory
Workspace root (if inside a project)
~/Movies/(macOS) or~/Videos/(Linux)~/Downloads/~/Desktop/
This allows natural commands like convert.sh demo.mov without specifying full paths.
HDR Handling
The script automatically detects HDR video content via ffprobe by checking for BT.2020 color primaries or SMPTE 2084 transfer characteristics. When HDR is detected, tonemapping is applied automatically to produce SDR-compatible GIF output with proper color preservation.
Use --tonemap to select the tonemapping algorithm:
| Algorithm | Characteristics |
|---|---|
| hable | Filmic curve, good highlight rolloff (default) |
| reinhard | Preserves more color saturation |
| mobius | Similar to reinhard with better highlights |
| bt2390 | ITU standard, more conservative |
Parameters Reference
| Parameter | Flag (bash) | Flag (PowerShell) | Default | Description |
|---|---|---|---|---|
| Input file | --input | -InputPath | (required) | Source video file path |
| Output file | --output | -OutputPath | input.gif | Destination GIF file path |
| Frame rate | --fps | -Fps | 10 | Frames per second |
| Width | --width | -Width | 1280 | Output width in pixels |
| Dithering | --dither | -Dither | sierra2_4a | Dithering algorithm |
| Tonemapping | --tonemap | -Tonemap | hable | HDR tonemapping algorithm |
| Skip palette | --skip-palette | -SkipPalette | false | Use single-pass mode |
| Start time | --start | -Start | 0 | Start time in seconds |
| Duration | --duration | -Duration | (full video) | Duration to convert in seconds |
| Loop count | --loop | -Loop | 0 | GIF loop count (0 = infinite) |
| Timeout | VIDEO_TO_GIF_TIMEOUT (env) | -TimeoutSeconds | 600 | Seconds allowed for each ffprobe/ffmpeg run |
The output path must differ from the input path. Both scripts refuse to run when the output resolves to the input, which includes the default output for a .gif input, so pass an explicit output path in that case. An existing file at a different output path is overwritten.
Each ffprobe and ffmpeg invocation is stopped when it exceeds the timeout. When the HDR probe fails or times out, the input is treated as SDR and conversion continues.
Frame Rate (FPS)
FPS controls animation smoothness and file size. Lower values reduce file size but create choppier motion.
| FPS | Use Case |
|---|---|
| 5 | Simple animations, icons |
| 10 | General use (default) |
| 15 | Smooth motion, UI demos |
| 24 | Near-video quality |
Width
Width sets the output horizontal resolution in pixels. Height scales proportionally to maintain aspect ratio.
| Width | Use Case |
|---|---|
| 320 | Thumbnails, previews |
| 640 | Documentation |
| 800 | Presentations |
| 1280 | High detail (default) |
Dithering Algorithms
Dithering determines how the 256-color GIF palette approximates the original colors.
| Algorithm | Quality | Speed | Best For |
|---|---|---|---|
| sierra2_4a | High | Medium | General use (default) |
| floyd_steinberg | High | Slow | Photographic content |
| bayer | Medium | Fast | Graphics with solid colors |
| none | Low | Fastest | Stylized/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 10Loop Control
Use --loop to control GIF repeat behavior:
| Value | Behavior |
|---|---|
| 0 | Loop forever |
| 1 | Play once |
| N | Play 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.gifTwo-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.gifSingle-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-paletteconvert.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 -SkipPaletteExamples
HDR Video Conversion
HDR content is detected automatically. No special flags are needed:
scripts/convert.sh hdr-footage.movThe 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 reinhardTime 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 15Documentation Thumbnails
Create compact thumbnails for documentation:
scripts/convert.sh --input demo.mp4 --width 320 --fps 8Troubleshooting
FFmpeg not found
Verify FFmpeg is in your PATH:
which ffmpeg # macOS/Linux
where.exe ffmpeg # WindowsIf FFmpeg is installed but not found, add its directory to your PATH environment variable.
File not found
Ensure the file exists at the specified path. If providing only a filename, the script searches the workspace first, then common directories (~/Movies/, ~/Downloads/, ~/Desktop/). Use an absolute path if the file is in a different location.
Output file is too large
Reduce file size with these adjustments:
Lower FPS (try 8 or 5)
Reduce width (try 640 or 320)
Use
bayerdithering for faster processingUse
--durationto convert only a portion of the video
Colors appear washed out
Switch to floyd_steinberg dithering for photographic content. Avoid none dithering unless a stylized look is intended.
HDR content looks wrong
Ensure FFmpeg 4.0+ is installed with zscale filter support. The script requires libzimg for HDR tonemapping. Install via:
# macOS
brew install zimg
brew reinstall ffmpeg
# Ubuntu
sudo apt install libzimg-devIf colors still appear off, try a different tonemapping algorithm with --tonemap. The reinhard algorithm preserves more saturation, while bt2390 provides more conservative results.
Conversion fails with filter error
Ensure FFmpeg version 4.0 or later is installed. The palettegen and paletteuse filters require this version.
ffmpeg -versionTemporary palette file remains
The scripts clean up /tmp/palette.png (or $env:TEMP\palette.png on Windows) automatically. If conversion fails mid-process, remove this file manually.
Files
- ATTRIBUTION.mdAdded by AutoGineer833 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SECURITY.md17.6 KiB
- SKILL.md10.8 KiB
- examples/README.md4.3 KiB
- scripts/convert.ps1Script20.2 KiB
- scripts/convert.shScript14.0 KiB
- tests/convert.Integrity.Tests.ps1Script13.3 KiB
- tests/convert.Tests.ps1Script8.9 KiB
- tests/convert.sh.Tests.ps1Script9.1 KiB
tests/convert.Tests.ps1
#Requires -Modules Pester
# Copyright (c) 2026 Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
BeforeAll {
function global:ffmpeg { param([Parameter(ValueFromRemainingArguments = $true)] [object[]]$Args) }
function global:ffprobe { param([Parameter(ValueFromRemainingArguments = $true)] [object[]]$Args) }
. (Join-Path $PSScriptRoot '../scripts/convert.ps1') -InputPath 'video.mp4'
Mock Write-Host {}
Mock Write-Error {}
}
AfterAll {
# Remove the ffmpeg/ffprobe stubs so they do not leak into later test suites
Remove-Item -Path 'Function:\ffmpeg' -Force -ErrorAction SilentlyContinue
Remove-Item -Path 'Function:\ffprobe' -Force -ErrorAction SilentlyContinue
}
Describe 'Format-FileSize' -Tag 'Unit' {
It 'Formats bytes values below one kilobyte' {
Format-FileSize -Bytes 512 | Should -Be '512 bytes'
}
It 'Formats values in the kilobyte range' {
Format-FileSize -Bytes 1536 | Should -Be '1.50 KB'
}
It 'Formats values in the megabyte range' {
Format-FileSize -Bytes 2.5MB | Should -Be '2.50 MB'
}
}
Describe 'Test-FFmpegAvailable' -Tag 'Unit' {
It 'Returns false when ffmpeg is not installed' {
Mock Get-Command { $null } -ParameterFilter { $Name -eq 'ffmpeg' }
Test-FFmpegAvailable | Should -BeFalse
}
It 'Returns true when ffmpeg is installed' {
Mock Get-Command { [pscustomobject]@{ Name = 'ffmpeg' } } -ParameterFilter { $Name -eq 'ffmpeg' }
Test-FFmpegAvailable | Should -BeTrue
}
}
Describe 'Find-VideoFile' -Tag 'Unit' {
BeforeEach {
Push-Location $TestDrive
Mock git { $global:LASTEXITCODE = 0; return $null }
}
AfterEach {
Pop-Location
}
It 'Returns the resolved path for an existing video file' {
$videoPath = Join-Path $TestDrive 'sample.mp4'
Set-Content -Path $videoPath -Value 'video' -NoNewline
$result = Find-VideoFile -Filename 'sample.mp4'
$result | Should -Not -BeNullOrEmpty
$result | Should -Be (Resolve-Path -Path $videoPath).Path
}
It 'Returns null for a missing video file' {
$result = Find-VideoFile -Filename 'missing-video.mp4'
$result | Should -BeNullOrEmpty
}
}
Describe 'Test-HDRContent' -Tag 'Unit' {
It 'Returns false when ffprobe is unavailable' {
Mock Get-Command { $null } -ParameterFilter { $Name -eq 'ffprobe' }
Test-HDRContent -FilePath 'video.mp4' | Should -BeFalse
}
It 'Returns true when ffprobe reports HDR color metadata' {
Mock Get-Command { [pscustomobject]@{ Name = 'ffprobe' } } -ParameterFilter { $Name -eq 'ffprobe' }
Mock Invoke-BoundedProcess { [pscustomobject]@{ ExitCode = 0; StdOut = 'bt2020' } }
Test-HDRContent -FilePath 'video.mp4' | Should -BeTrue
}
It 'Returns false when ffprobe reports SDR content' {
Mock Get-Command { [pscustomobject]@{ Name = 'ffprobe' } } -ParameterFilter { $Name -eq 'ffprobe' }
Mock Invoke-BoundedProcess { [pscustomobject]@{ ExitCode = 0; StdOut = 'bt709' } }
Test-HDRContent -FilePath 'video.mp4' | Should -BeFalse
}
}
Describe 'Invoke-SinglePassConversion' -Tag 'Unit' {
It 'Returns true when the single-pass command exits successfully' {
Mock Invoke-FFmpegProcess { return $true }
$result = Invoke-SinglePassConversion -SourcePath 'video.mp4' -DestinationPath 'output.gif' -LoopCount 0 -BaseFilter 'fps=10' -TimeArgs @(-1)
$result | Should -BeTrue
Should -Invoke Invoke-FFmpegProcess -Times 1 -Exactly
}
It 'Forwards the configured timeout to the ffmpeg process wrapper' {
Mock Invoke-FFmpegProcess { return $true }
Invoke-SinglePassConversion -SourcePath 'video.mp4' -DestinationPath 'output.gif' -LoopCount 0 -BaseFilter 'fps=10' -TimeArgs @(-1) -TimeoutSeconds 42 | Out-Null
Should -Invoke Invoke-FFmpegProcess -Times 1 -Exactly -ParameterFilter { $TimeoutSeconds -eq 42 }
}
}
Describe 'Invoke-TwoPassConversion' -Tag 'Unit' {
BeforeEach {
$env:TEMP = $TestDrive
}
AfterEach {
Remove-Item Env:TEMP -ErrorAction SilentlyContinue
}
It 'Removes the temporary palette directory after a successful conversion' {
$script:capturedPalette = $null
$destinationPath = Join-Path $TestDrive 'output.gif'
Mock Invoke-FFmpegProcess {
$paletteArg = $Arguments | Where-Object { $_ -is [string] -and $_ -like '*palette.png' }
if ($paletteArg) {
$script:capturedPalette = $paletteArg
Set-Content -Path $paletteArg -Value 'palette' -NoNewline
}
return $true
}
$result = Invoke-TwoPassConversion -SourcePath 'video.mp4' -DestinationPath $destinationPath -DitherAlgorithm 'bayer' -LoopCount 0 -BaseFilter 'fps=10' -TimeArgs @(-1)
$result | Should -BeTrue
$script:capturedPalette | Should -Not -BeNullOrEmpty
Test-Path -Path $script:capturedPalette | Should -BeFalse
Test-Path -Path (Split-Path -Parent $script:capturedPalette) | Should -BeFalse
}
It 'Returns false when palette generation fails' {
Mock Invoke-FFmpegProcess { return $false }
$result = Invoke-TwoPassConversion -SourcePath 'video.mp4' -DestinationPath 'output.gif' -DitherAlgorithm 'bayer' -LoopCount 0 -BaseFilter 'fps=10' -TimeArgs @(-1)
$result | Should -BeFalse
}
}
Describe 'Invoke-VideoConversion' -Tag 'Unit' {
BeforeEach {
Mock Test-FFmpegAvailable { $true }
Mock Test-HDRContent { $false }
Mock Find-VideoFile { 'video.mp4' }
}
It 'Uses the two-pass path and formats the output size when conversion succeeds' {
$outputPath = Join-Path $TestDrive 'converted.gif'
$outputDir = Split-Path -Parent $outputPath
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
Mock Invoke-TwoPassConversion {
Set-Content -Path $DestinationPath -Value 'gif-data' -NoNewline
return $true
}
Mock Invoke-SinglePassConversion { throw 'single pass should not be used' }
{ Invoke-VideoConversion -InputPath 'video.mp4' -OutputPath $outputPath -Start 5 -Duration 10 } | Should -Not -Throw
Should -Invoke Invoke-TwoPassConversion -Times 1 -Exactly
(Get-Item -Path $outputPath).Length | Should -BeGreaterThan 0
}
It 'Uses a default output path derived from an existing input file' {
$sourcePath = Join-Path $TestDrive 'sample.mp4'
Set-Content -Path $sourcePath -Value 'video' -NoNewline
Mock Invoke-TwoPassConversion {
Set-Content -Path $DestinationPath -Value 'gif-data' -NoNewline
return $true
}
{ Invoke-VideoConversion -InputPath $sourcePath } | Should -Not -Throw
Test-Path -Path (Join-Path $TestDrive 'sample.gif') | Should -BeTrue
Should -Invoke Invoke-TwoPassConversion -Times 1 -Exactly
}
It 'Applies the HDR-specific filter path when HDR content is detected' {
$outputPath = Join-Path $TestDrive 'hdr.gif'
New-Item -ItemType Directory -Path $TestDrive -Force | Out-Null
Mock Test-HDRContent { $true }
Mock Invoke-TwoPassConversion {
Set-Content -Path $DestinationPath -Value 'gif-data' -NoNewline
return $true
}
{ Invoke-VideoConversion -InputPath 'video.mp4' -OutputPath $outputPath -Start 5 -Duration 10 } | Should -Not -Throw
Should -Invoke Invoke-TwoPassConversion -Times 1 -Exactly -ParameterFilter { $BaseFilter -match 'tonemap' }
}
It 'Throws when the input file cannot be found' {
Mock Find-VideoFile { $null }
{ Invoke-VideoConversion -InputPath 'missing-video.mp4' } | Should -Throw '*Input file not found*'
}
It 'Uses the single-pass path when SkipPalette is supplied' {
$outputPath = Join-Path $TestDrive 'single-pass.gif'
$outputDir = Split-Path -Parent $outputPath
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
Mock Invoke-SinglePassConversion {
Set-Content -Path $DestinationPath -Value 'gif-data' -NoNewline
return $true
}
Mock Invoke-TwoPassConversion { throw 'two pass should not be used' }
{ Invoke-VideoConversion -InputPath 'video.mp4' -OutputPath $outputPath -SkipPalette } | Should -Not -Throw
Should -Invoke Invoke-SinglePassConversion -Times 1 -Exactly
Should -Invoke Invoke-TwoPassConversion -Times 0 -Exactly
}
It 'Throws when the helper reports conversion failure' {
$outputPath = Join-Path $TestDrive 'failed.gif'
$outputDir = Split-Path -Parent $outputPath
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
Mock Invoke-TwoPassConversion { return $false }
Mock Invoke-SinglePassConversion { return $false }
{ Invoke-VideoConversion -InputPath 'video.mp4' -OutputPath $outputPath } | Should -Throw '*Conversion failed*'
}
}
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool
The author says: Requires FFmpeg on PATH
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/hve-core · .github/skills/experimental/video-to-gif · commit f425e94
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download video-to-gif.zip