Skip to content

Commit 229a6dd

Browse files
committed
Add shorten_factor parameter to recording-to-gif.sh
1 parent 82dfaee commit 229a6dd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

demos/recording-to-gif.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ if [ ! -z "$2" ]; then
1414
scale=$2
1515
fi
1616

17+
# By default, speed up the video by 4x
18+
shorten_factor=0.25
19+
20+
# Check if user provided a speed-up parameter
21+
if [ ! -z "$3" ]; then
22+
shorten_factor=$3
23+
fi
24+
1725
# Get input file name without extension
1826
input_file="${1%.*}"
1927

2028
# Set output file name with .gif extension
2129
output_file="$input_file.gif"
2230

2331
# Use FFmpeg to make the GIF
24-
ffmpeg -i "$1" -vf "setpts=0.5*PTS,fps=15,scale=iw/${scale}:ih/${scale}:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "$output_file"
32+
ffmpeg -i "$1" -vf "setpts=${shorten_factor}*PTS,fps=15,scale=iw/${scale}:ih/${scale}:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "$output_file"
2533

2634
echo "GIF conversion complete. Output file: $output_file"

0 commit comments

Comments
 (0)