#!/bin/bash # ====================================================== # Extract First Frame as Poster for All Videos # ====================================================== # This script goes through all .mp4 and .webm files in the current # folder and extracts the very first frame as a high-quality poster image. # # Usage: # cd /home/khan/code/shahikitchen/public/videos # bash /home/khan/code/shahikitchen/extract-video-posters.sh # # Requirements: # - ffmpeg installed # # Output: # For butter-chicken-steam.mp4 → butter-chicken-steam-poster.jpg # (You can then update your menu data or code to use these posters) # ====================================================== set -e echo "Extracting first frame posters from videos..." echo "" for file in *.mp4 *.webm; do if [ ! -f "$file" ]; then continue fi base="${file%.*}" output="${base}-poster.jpg" # Skip if poster already exists if [ -f "$output" ]; then echo "→ Skipping $file (poster already exists)" continue fi echo "→ Extracting poster from: $file" ffmpeg -y -i "$file" -ss 0.1 -vframes 1 -q:v 2 "$output" 2>/dev/null if [ -f "$output" ]; then echo " Created: $output" else echo " Failed to create poster for $file" fi done echo "" echo "✅ Done extracting posters!" echo "" echo "You can now update your menu cards to use *-poster.jpg instead of the original dish photos" echo "for better visual consistency between static state and video."