summaryrefslogtreecommitdiffstats
path: root/tools/image_extract
diff options
context:
space:
mode:
Diffstat (limited to 'tools/image_extract')
-rwxr-xr-xtools/image_extract20
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/image_extract b/tools/image_extract
index c1bf633..bdf984d 100755
--- a/tools/image_extract
+++ b/tools/image_extract
@@ -8,7 +8,11 @@
EXT=`echo "$1"|awk -F . '{print $NF}'`
BASENAME=`basename $1 .$EXT`
+
DURATION=`./duration $1`
+RESOLUTION=`./video_resolution $1`
+THUMB="320x240"
+
OLD_IFS="$IFS"
IFS=":"
TIME=( $DURATION )
@@ -21,12 +25,14 @@ if [ -z "$1" ]; then
exit 1
fi
-if [ -f $BASENAME.jpg ] ; then
- echo " * Image thumbnail already exist."
- exit 1
-fi
+./require ffmpeg || { exit 1; }
+./require convert || { exit 1; } #imagemagick
+
+echo -n " * Extracting image ($RESOLUTION) from video (frame $SECOND s)..."
+ffmpeg -itsoffset -$SECOND -i $1 -vcodec mjpeg -vframes 1 -an -f rawvideo -s $RESOLUTION $BASENAME.jpeg \
+> "$BASENAME.jpeg-compresslog" 2>&1
+echo -e "OK!"
-echo -n " * Extracting image thumbnail from video (frame $SECOND s)..."
-ffmpeg -itsoffset -$SECOND -i $1 -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 $BASENAME.jpg \
-> "$BASENAME.jpg-compresslog" 2>&1
+echo -n " * Resizing image to thumbnail ($THUMB)..."
+convert -resize $THUMB $BASENAME.jpeg $BASENAME-thumb.jpeg
echo -e "OK!"