[mythtv-users] MythVideo Thumbnails

Aaron Segaert segaera at mcmaster.ca
Fri Feb 24 16:59:48 UTC 2006


On Wed, 15 Feb 2006 14:25:57 -0500 Aaron Segaert wrote:

/Instead of getting movie posters from IMDB, is it possible for 
MythVideo to use thumbnail previews, like the movie previews in Gnome's 
  Nautilus or Windows Explorer? Perhaps someone has patch/hack to do 
this?  I wish I could do it myself, but I'm not a programmer. The reason 
I  bring this up is because hardly any of my videos have cover art and 
therefore MythVideo really doesn't look nice, no matter  if using list, 
browse  or gallery mode./




I figured out a way to do this.  Here are the scripts used.  There's 
probably a better way to do it but as I said, I'm no programmer.  The 
scripts look in the mythconverg database for videos with "No Cover", 
then it uses mplayer to generate a thumbnail.  Lastly, it updates the 
myth database with the new cover images.  This gives anyone interested a 
basis for making their own script.  Thanks to others who responded to my 
post for their ideas.

Note that there are four scripts, the main script, and three mysql 
scripts that are called from the main script. Also note that I lazily 
hardcoded my paths (I made a new directory ~/.mythtv/MythVideo/scripts 
to contain the output files), and the mysql lines will need to contain 
the mythconverg password, If you want to use these, obviously you'll 
have to change them. To use the script, simply execute the main script 
from the command line.

Here's the main script:


#!/bin/sh

until [ "$count" = "0" ]
do

  ##find out how many movies to process
  mysql -u mythtv -p****** < 
/home/user/.mythtv/MythVideo/scripts/movielist.sql > 
/home/user/.mythtv/MythVideo/scripts/sqllist.out
  count=`wc -l /home/user/.mythtv/MythVideo/scripts/sqllist.out | awk 
'{print $1}'`


  ##get a  movie to process
  mysql -u mythtv -p****** < 
/home/user/.mythtv/MythVideo/scripts/moviefind.sql > 
/home/user/.mythtv/MythVideo/scripts/sql.out
  MOVIE="`cat /home/user/.mythtv/MythVideo/scripts/sql.out | grep -v 
title | grep -v filename | grep /opt`"
  MOVIEID="`cat /home/user/.mythtv/MythVideo/scripts/sql.out | grep -v 
filename | grep -v title | grep -v /opt`"

  ##create the thumbnail using mplayer
  mplayer -ss 00:5:44 -vo 
jpeg:quality=95:outdir=/home/user/.mythtv/MythVideo/scripts/ -frames 1 
-nosound "$MOVIE"
  mv /home/user/.mythtv/MythVideo/scripts/00000002.jpg 
/home/user/.mythtv/MythVideo/"$MOVIEID".jpg

  ##update the database
  mysql -u mythtv -p****** < 
/home/user/.mythtv/MythVideo/scripts/movieupdate.sql

done



And here are the mysql scripts:

put these two lines in a file called "movielist.sql"

USE mythconverg
SELECT filename FROM `videometadata` WHERE `coverfile` = 'No Cover';



Put these lines in a file called "moviefind.sql"

USE mythconverg
SELECT filename FROM `videometadata` WHERE `coverfile` = 'No Cover' 
LIMIT 1;
SELECT title FROM `videometadata` WHERE `coverfile` = 'No Cover' LIMIT 1;



Put these lines in a file called "movieupdate.sql"

USE mythconverg

SELECT @var_MOVIEID:=`title` FROM `videometadata` WHERE `coverfile` = 
'No Cover' LIMIT 1;
SELECT @var_MOVIEID;

SET @var_dir = "/home/user/.mythtv/MythVideo/";
SET @var_jpg = ".jpg";
SET @var_MOVIETHUMB = CONCAT(@var_dir, at var_MOVIEID, at var_jpg) ;
SELECT @var_dir, @var_jpg, @var_MOVIETHUMB;

UPDATE `videometadata` SET `coverfile` = @var_MOVIETHUMB WHERE `title` = 
@var_MOVIEID LIMIT 1 ;











More information about the mythtv-users mailing list