Skip to content

Instantly share code, notes, and snippets.

@VicoErv
Created August 22, 2025 13:21
Show Gist options
  • Save VicoErv/29bfa31d52beb903494b5bc9b609db3f to your computer and use it in GitHub Desktop.
Save VicoErv/29bfa31d52beb903494b5bc9b609db3f to your computer and use it in GitHub Desktop.
simplified gif creation for discord or tenor
function mkgif {
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$InputFile,
[Parameter(Mandatory=$true, Position=1)]
[string]$OutputFile,
[Parameter(Mandatory=$false)]
[int]$StartTime = 0,
[Parameter(Mandatory=$false)]
[int]$Duration = 3,
[Parameter(Mandatory=$false)]
[int]$FPS = 10,
[Parameter(Mandatory=$false)]
[int]$Width = 320
)
$ffmpegCmd = "ffmpeg -ss $StartTime -t $Duration -i `"$InputFile`" -vf `"fps=$FPS,scale=${Width}:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse`" -loop 0 `"$OutputFile`""
Write-Host "Converting $InputFile to $OutputFile..." -ForegroundColor Green
Write-Host "Command: $ffmpegCmd" -ForegroundColor Yellow
Invoke-Expression $ffmpegCmd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment