Last active
December 24, 2024 03:23
-
-
Save mdashlw/5e840cd082a7b9d6bb824a888716dc34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| file="$1" | |
| file_nut="${file%.*}.nut" | |
| file_gif="${file%.*}.gif" | |
| width=${2:-5000} | |
| fixlum="[v]geq=lum='if(eq(alpha(X,Y),0),16,p(X,Y))':a='p(X,Y)':cb_expr='p(X,Y)'[o]" | |
| cropvalue=$(ffmpeg -i "$file" -map v -vf "$fixlum;[o]cropdetect=mode=black:limit=0" -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1) | |
| ffmpeg -i "$file" -map v -vf "$fixlum;[o]$cropvalue" -c rawvideo -y "$file_nut" | |
| fps=$(ffprobe -show_streams "$file" 2>&1 | grep fps | awk '{split($0,a,"fps")}END{print a[1]}' | awk '{print $NF}') | |
| gifski -o "$file_gif" --width $width --fps "$fps" --extra --quiet --quality 100 "$file_nut" | |
| rm "$file_nut" |
This file contains hidden or 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
| #!/bin/bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| file="$1" | |
| file_nut="${file%.*}.nut" | |
| file_gif="${file%.*}.gif" | |
| cropvalue=$(ffmpeg -i "$file" -map v -vf "cropdetect=mode=black:limit=0" -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1) | |
| ffmpeg -i "$file" -map v -vf "$cropvalue" -c rawvideo "$file_nut" | |
| fps=$(ffprobe -show_streams "$file" 2>&1 | grep fps | awk '{split($0,a,"fps")}END{print a[1]}' | awk '{print $NF}') | |
| gifski -o "$file_gif" --width 5000 --fps "$fps" --extra --quiet --quality 100 "$file_nut" | |
| rm "$file_nut" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment