From fd13b1f439d0a716682630e6b4778ca2d0b8cf5c Mon Sep 17 00:00:00 2001 From: Calin Burloiu Date: Mon, 7 Mar 2011 13:27:18 +0200 Subject: [PATCH] thumnail extraction script added --- ffmpeg-extract-thumbnail | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 ffmpeg-extract-thumbnail 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" -- 2.20.1