Created
August 27, 2022 10:24
-
-
Save chsbuffer/86f4d18f05312b0fc078578aef55c38b to your computer and use it in GitHub Desktop.
GIF to Telegram Video Sticker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# play with filters and arguments to reduce file size lower than 256KB by yourself | |
$folder = Get-Item ".\gif" | |
$outFolder = Get-Item ".\outfolder" | |
Add-Type -AssemblyName System.Drawing | |
# Get-ChildItem $folder | Sort-Object Length -Descending | Select-Object -First 3 | ForEach-Object -ThrottleLimit 8 -Parallel { | |
Get-ChildItem $folder | ForEach-Object -ThrottleLimit 4 -Parallel { | |
$outFolder = $using:outFolder # comment out if Parallel disabled | |
$img = [System.Drawing.Image]::FromFile($_.FullName) | |
$width = $img.Width | |
$height = $img.Height | |
if ($width -gt $height) { | |
$scale = "scale=512:-1" | |
} else { | |
$scale = "scale=-1:512" | |
} | |
# -b:v # bitrate | |
# -vf # video filters | |
# nlmeans=s=10 # denoise level 10 (1~30) | |
# fps=30 | |
# setpts=0.5*PTS # 2x speed | |
$filters = "" | |
ffmpeg -i $_.FullName -vcodec libvpx-vp9 -an -vf "$scale,$filters" -pix_fmt yuva420p -y "$outFolder\$($_.BaseName).webm" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment