18 lines
1.5 KiB
PowerShell
18 lines
1.5 KiB
PowerShell
param(
|
|
# powershell is factually gay idkl why its such a shit
|
|
[Parameter(Mandatory=$True, Position=0)] # deband the param, its in position 0 so ya canb just ffmpreg_gif_loopy filename.mp4 OR ffmpreg_gif_loopy -Filename filename.mp4
|
|
[string]$Filename # var for filename string
|
|
)
|
|
# apng is far hjigher quality and also preserves transparancy :activated:
|
|
$noextpath = [System.IO.Path]::GetFileNameWithoutExtension($Filename) # get filename without extension
|
|
$gifpath = "$noextpath`_MAXLOOP.gif" # add da .gif extension and MAXLOOP tag
|
|
|
|
# ffmpeg
|
|
## -i input file (mp4)
|
|
## settings for -filter_complex purely vibe coded for max quality
|
|
### split [a][b]: Splitting clones the video stream into two identical, simultaneous feeds. This lets you process the color palette and render the GIF all in one
|
|
### palettegen=stats_mode=single: This generates the highest quality 256-color palette based strictly on the exact colors present in your video. Changing the mode to single tells FFmpeg to optimize colors for moving objects across frames.
|
|
### paletteuse=dither=bayer:bayer_scale=5: This dictates how colors are blended. Using a strict bayer dither with a scale of 5 keeps gradients incredibly clean and crisp, eliminating the ugly "cross-hatch" or "grainy" patterns typical of basic GIFs
|
|
## -loop 0 maek da gif loop
|
|
## outputfile (gif)
|
|
ffmpeg -i "$Filename" -filter_complex "[0:v] split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=dither=bayer:bayer_scale=5" -loop 0 "$gifpath" |