[mythtv-users] mythvideo thumbnails

Robert Logan bert at p3rf3ct.com
Tue Apr 17 16:12:27 UTC 2007


I trawled around trying to find a tool that would do at
least a part of the 'imdb.pl' job of creating a thumbnail
of my own personal videos (baby crawling for 1st time,
baby walking for 1st time, me scoring fabulous goal at
five a side etc).

Ta da - i fudged this up - no great error checking,
but does the job - look for the '\' where the line shouldn't
be broken - but its fairly self explanatory - run with
a simple: vidthumbs.sh xxx.mpg

----CUT---
#!/bin/bash
# vidthumbs.sh
# create video thumbnails for myhtvideo v1.1
# no real error checking etc

# where the thumbs will go to! (used by mythvideo)
outdir="/mythtv/.mythtv/MythVideo"

# get the length - use 1/4 of it for the grab - if no
# length then 15 secs in is ok!
len=`mplayer -identify "$1" -nosound -vc duff -vo null 2>&1 \
	| grep ID_LENGTH | cut -f2 -d'=' | cut -f1 -d'.'`
if [ ! "X$len" = "X" ]; then
   offset=`expr $len / 4 + 1`
else
   offset=15
fi
echo $offset $1

# mplayer can grab the 7 frames at this offset, just use
# the 6th one (no reason)
mplayer -zoom -ss $offset -nosound -vo jpeg:outdir=$outdir \
	-frames 7 -vf scale=250:-3 "$1" > /dev/null 2>&1

# use the 6th - rename it to the filename
mv $outdir/00000006.jpg $outdir/$1.jpg

# clean up
rm -f $outdir/000000*.jpg

coverfile="$outdir/$1.jpg"

# mythtv stores filename 'titles' with '.' and '_' as
# spaces and chop off the extension part
# so title of "mvi_0001a.111.avi" will become "mvi 0001a 111"
title=`echo $1 | rev | cut -f2- -d'.' | rev | sed "s/\./ /g" \
	| sed "s/_/ /g"`

# associate the title with the jpg created using a bit of SQL
sql="update mythconverg.videometadata set coverfile='$coverfile' \
	where title='$title'"

mysql -u mythtv -pmythtv mythconverg --execute="$sql"


More information about the mythtv-users mailing list