From: Calin Burloiu Date: Mon, 7 Mar 2011 11:27:18 +0000 (+0200) Subject: thumnail extraction script added X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=fd13b1f439d0a716682630e6b4778ca2d0b8cf5c;p=video-handling.git thumnail extraction script added --- diff --git a/ffmpeg-extract-thumbnail b/ffmpeg-extract-thumbnail new file mode 100755 index 0000000..92e4a1d --- /dev/null +++ b/ffmpeg-extract-thumbnail @@ -0,0 +1,28 @@ +#!/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"