Created
June 21, 2023 02:20
-
-
Save royshil/8ceee60d331074d83cd5dd5187c28ce1 to your computer and use it in GitHub Desktop.
Various flavors of video-to-GIF scripts
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
# Convert the video to a 480x GIF @ x2 speed | |
file1=$(basename -- "$1") | |
dir=$(dirname "$1") | |
file1="${file1%.*}" | |
/usr/local/bin/ffmpeg -hide_banner -loglevel panic -i "$1" -filter_complex "[0:v] scale=w='min(480,iw)':h=-1,fps=8,setpts=(1/2)*PTS, split [a][b]; [a] palettegen [p]; [b][p] paletteuse" -y "$dir/$file1.gif" |
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
# Convert the video to a 720x GIF @ x2 speed | |
file1=$(basename -- "$1") | |
dir=$(dirname "$1") | |
file1="${file1%.*}" | |
/usr/local/bin/ffmpeg -hide_banner -loglevel panic -i "$1" -filter_complex "[0:v] scale=h='min(720,ih)':w=-1,fps=8,setpts=(1/2)*PTS, split [a][b]; [a] palettegen [p]; [b][p] paletteuse" -y "$dir/$file1.gif" |
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
# Convert the video to GIF at full resolution @ x2 speed | |
file1=$(basename -- "$1") | |
dir=$(dirname "$1") | |
file1="${file1%.*}" | |
/usr/local/bin/ffmpeg -hide_banner -loglevel panic -i "$1" -filter_complex "[0:v]fps=8,setpts=(1/2)*PTS, split [a][b]; [a] palettegen [p]; [b][p] paletteuse" -y "$dir/$file1.gif" |
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
# Converts a video to a gif | |
# get the filename without extension | |
$file1 = [System.IO.Path]::GetFileNameWithoutExtension($args[0]) | |
# get the directory name | |
$dir = [System.IO.Path]::GetDirectoryName($args[0]) | |
Write-Host "Converting " $args[0] " to $dir/$file1.gif" | |
# create the gif | |
ffmpeg -hide_banner -loglevel panic -i $args[0] -filter_complex ` | |
"[0:v]fps=8,setpts=(1/2)*PTS, split [a][b]; [a] palettegen [p]; [b][p] paletteuse" ` | |
-y "$dir/$file1.gif" |
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
# Convert the video to a 480x GIF @ x100 speed | |
file1=$(basename -- "$1") | |
dir=$(dirname "$1") | |
file1="${file1%.*}" | |
/usr/local/bin/ffmpeg -hide_banner -loglevel panic -i "$1" -filter_complex "[0:v] scale=w=480:h=-1,fps=12,setpts=(1/100)*PTS, split [a][b]; [a] palettegen [p]; [b][p] paletteuse" -y "$dir/$file1.gif" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment