Add ffmpeg function to convert video to gif

This commit is contained in:
Sheldon Lee 2024-10-31 00:22:39 +08:00
parent 3c3ed20f8d
commit 3465007ba6

View File

@ -0,0 +1,10 @@
#!/bin/bash
function video_to_gif() {
if [ "$#" -ne 4 ]; then
echo "Usage: video_to_gif input.mp4 output.gif start duration"
return 1
fi
ffmpeg -ss "$3" -t "$4" -i "$1" \
-vf "fps=24,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
-loop 0 "$2"
}