PDA

View Full Version : HOW-TO create a video thumbnail under Linux


SandmanCL
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:


#!/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.

Gamester17
2007-12-10, 14:04
Feel free to update this wiki article on how-to do it for Linux as well:
http://www.xboxmediacenter.com/wiki/index.php?title=HOW-TO:_Create_video-preview_thumbnails

Just make sure to make seperate sections in it for Windows and Linux.

:;):

Gamester17
2007-12-12, 15:32
FYI; this was added to the Linux port branch of XBMC late yesterday:extract frame from video files without thumb. experimental.Let's hope this feature gets ported back to the Xbox trunk as well :;):

OwlBoy
2008-01-07, 01:29
Works good on Mac OS X with mplayer installed through darwinports or fink.

-Owl

HarshReality
2008-10-14, 13:26
Old thread bully for me for reviving a dinosaur.. yes Ive been gone awhile..

Anyway, does anybody have or know of a way of duplicating the effect of the old photoshop actionscript (3D tilt) for thumbs under linux (havent tried it with Wine so cant say if that would work) Im curious if there is a completely native linux way of doing it.

freezy
2008-10-14, 13:41
Old thread bully for me for reviving a dinosaur.. yes Ive been gone awhile..

Anyway, does anybody have or know of a way of duplicating the effect of the old photoshop actionscript (3D tilt) for thumbs under linux (havent tried it with Wine so cant say if that would work) Im curious if there is a completely native linux way of doing it.

yeah i've wrote a php script using the imagick library. you'll need the both-sides cover scan from cdcovers.cc or similar though. atm the latest covers are daily fetched from cdcovers.cc and uploaded tilted to mediaicons.org. if you want i can paste the script somewhere.