Last active
February 16, 2026 16:10
-
-
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.
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
| #!/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