#!/bin/bash # ====================================================== # Video Optimization Script for Shahi Kitchen Website # ====================================================== # # This script creates optimized .webm versions of your MP4 videos. # # IMPORTANT: # - It will NOT delete or modify any of your original .mp4 files. # - It only creates new .webm files next to them. # - Keep both versions for now. We can decide later. # # Target: 480p, ~550-700 kbps, VP9 # # Requirements: # Ubuntu/Debian: sudo apt update && sudo apt install ffmpeg # macOS: brew install ffmpeg # # Usage: # cd /home/khan/code/shahikitchen/public/videos # bash /home/khan/code/shahikitchen/optimize-videos.sh # ====================================================== set -e echo "Starting video optimization (WebM only)..." echo "Your original .mp4 files will NOT be touched or deleted." echo "" for file in *.mp4; do if [ ! -f "$file" ]; then continue fi base="${file%.mp4}" # Skip if .webm already exists if [ -f "${base}.webm" ]; then echo "→ Skipping ${file} (webm already exists)" continue fi echo "→ Processing: $file → ${base}.webm" ffmpeg -y -i "$file" \ -c:v libvpx-vp9 -b:v 600k -crf 34 -deadline good -cpu-used 3 \ -vf "scale=854:480" \ -an \ -r 24 \ "${base}.webm" echo " Created: ${base}.webm" done echo "" echo "✅ Optimization complete!" echo "" echo "New .webm files have been created next to your original .mp4 files." echo "Your website code is already set up to prefer .webm when available." echo "" echo "Next steps when you're ready:" echo "1. Test the site locally (WebM should load much faster and use less data)." echo "2. Let me know when you want to decide what to do with the old MP4s."