Created
April 23, 2025 02:10
-
-
Save kyeongan/52db90ebf8ac7d821ad1d25525469d73 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 | |
# gif_to_mp4_5x.sh | |
# Convert GIF to 5x speed MP4 using ffmpeg. | |
INPUT="$1" | |
BASENAME=$(basename "$INPUT" .gif) | |
SPEED=1 | |
PTS=$(awk "BEGIN{print 1/$SPEED}") | |
WIDTH=1000 # Desired output width (px) | |
if [[ -z "$INPUT" ]]; then | |
echo "❗ Usage: $0 input.gif" | |
exit 1 | |
fi | |
echo "🖼️ Input GIF: $INPUT" | |
echo "⚡ Speed: ${SPEED}x | Resize to width: ${WIDTH}px" | |
ffmpeg -i "$INPUT" -vf "setpts=${PTS}*PTS,scale=${WIDTH}:-2:flags=lanczos" \ | |
-vcodec libx264 -pix_fmt yuv420p -crf 23 -preset slow -movflags +faststart \ | |
"${BASENAME}_${SPEED}x.mp4" | |
echo "✅ Done: ${BASENAME}_${SPEED}x.mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment