2007-12-09, 00:51
Since I find it useful, maybe others might as well, so I'm sharing
The mplayer syntax for creating a thumbnail is:
mplayer -ss <seconds> -nosound -vo jpeg -frames 2 <video filename>
So, to grab a frame 60 seconds into the latest episode of The Simpsons:
mplayer -ss 60 -nosound -vo jpeg -frames 2 simpsons.s19e08.avi
This will create a thumbnail named 00000001.jpg.
I wrapped this into a script I've named makethumb:
This script takes a filename as argument and produces a .tbn and a .jpg file with the same name as the video input.
The mplayer syntax for creating a thumbnail is:
mplayer -ss <seconds> -nosound -vo jpeg -frames 2 <video filename>
So, to grab a frame 60 seconds into the latest episode of The Simpsons:
mplayer -ss 60 -nosound -vo jpeg -frames 2 simpsons.s19e08.avi
This will create a thumbnail named 00000001.jpg.
I wrapped this into a script I've named makethumb:
Code:
#!/bin/sh
set -e # exit on any error
seconds=120
input=$1
if [ ! -z "$2" ]; then
seconds=$2
fi
log="/dev/null"
thumb=`echo $input | sed 's/\....$/.jpg/'`
xbox_thumb=`echo $thumb|sed 's/.jpg/.tbn/'`
if [ -f "$thumb" ]; then
echo "Recreating by increasing thumb value by 3 sec"
seconds=$(($seconds + 3))
rm -f "$thumb"
rm -f "$xbox_thumb"
fi
echo "=== Processing $input ==="
echo -n "Step 1: extracting frame ... "
mplayer -ss $seconds -nosound -vo jpeg -frames 2 "$input" > $log 2>&1 \
&& echo "[ ok ]" || echo "[ FAIL ]";
echo -n "Step 2: renaming thumb ... "
output=`ls -t 00000*.jpg | tail -1`
mv "$output" "$thumb" && echo "[ ok ]" || echo "[FAIL]"
ln "$thumb" "$xbox_thumb"
rm -f 00000*.jpg
This script takes a filename as argument and produces a .tbn and a .jpg file with the same name as the video input.