#!/bin/bash # # Calin-Andrei Burloiu, 2010, calin.burloiu@gmail.com # # This script extracts a thumbnail from a random frame of a video file. # # if test $# -ne 3; then echo "Usage: $0 input-video output-image resolution" exit 1 fi IN="$1" OUT="$2" RESOLUTION="$3" FFMPEG=/usr/bin/ffmpeg if test ! -f "$IN"; then echo "Error: No such file $IN" exit 1 fi # Choose a random frame DURATION=$(mediainfo --Inform="General;%Duration%" "$IN" | cut -d"." -f1) SEEK_POINT=$(($DURATION * $RANDOM / 32767 / 1000)) "$FFMPEG" -i "$IN" -ss "$SEEK_POINT" -vframes 1 -s "$RESOLUTION" -f image2 "$OUT"