Skip to content

Instantly share code, notes, and snippets.

@joshespi
Last active February 16, 2026 16:10
Show Gist options
  • Select an option

  • Save joshespi/da3cc421b4a686676e4cb9db86eeebba to your computer and use it in GitHub Desktop.

Select an option

Save joshespi/da3cc421b4a686676e4cb9db86eeebba to your computer and use it in GitHub Desktop.
Simple shrink a mp4 below 10mb. Discord limits to 10MB. I often have the issue where my videos are slightly above that. this will help make it uploadable.
#!/usr/bin/env bash
# Requires
# - ffmpeg
input="$1"
if [[ -z "$input" ]]; then
echo "Usage: shrink-video <input-video>"
exit 1
fi
if [[ ! -f "$input" ]]; then
echo "File not found: $input"
exit 1
fi
dir="$(dirname "$input")"
filename="$(basename "$input")"
ext="${filename##*.}"
# Remove extension
base="${filename%.*}"
# Strip trailing [xxxx] (common yt-dlp pattern)
clean_name="$(echo "$base" | sed -E 's/[[:space:]]*\[[^]]+\]$//')"
output="$dir/${clean_name}-shrunk.${ext}"
ffmpeg -i "$input" \
-vf "scale=640:360:force_original_aspect_ratio=decrease" \
-c:v libx264 -crf 28 -preset fast \
-c:a aac -b:a 96k \
-fs 10M \
"$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment