[mythtv-users] mythvideo thumbnails
Neil
damonkieman at hotmail.com
Wed Jun 6 22:17:54 UTC 2007
i've taken this scripts written by segaera and consolidated everything into one script. also, this script will run the query to get the videos to update only once, whereas segaera's is running once for each video. furthermore, this script takes the length of the video into account when skipping ahead for the screenshot position. a percentage is used instead of a fixed value to get a good capture in videos of widely varying lengths. here it is:#!/bin/sh# this script will loop through all videos in videometadata,# capture a screenshot for each, move each screenshot to the# COVERPATH dir, and update each row in videometadata with# the appropriate information. Only rows with coverfile=# 'No Cover' are processed. A percentage of the length# of each video is used for the capture position to account# for clips of widely varying lengths.# only run as mythtv so writing to /myth is allowedif [ $(whoami) != 'mythtv' ]; then echo "This script must run under user mythtv." exit 1fi# intialize variablesDB='mythconverg'USER='root'OUTPATH='/tmp'COVERPATH='/myth/video/.covers'FRAME='00000002.jpg'SKIPOFFSET='35'# query videos with no cover imageVIDEOS="mysql $DB -u $USER \ -e \"SELECT intid,filename FROM videometadata \ WHERE coverfile='No Cover';\" -BN" sh -c "$VIDEOS"|while read line#echo "$FILE"|while read linedo ID=`echo "$line" |cut -f 1` FILE=`echo "$line" |cut -f 2` echo "processing $FILE with primary key id $ID" # if video is mpeg, use ffmpeg12 codec to avoid pixelation if echo "$FILE" | egrep ".*\.mp[e]*g" ; then VC='-vc ffmpeg12' else VC='' fi # use mplayer to get length of video in seconds length=`mplayer -vo null -nosound -identify \ -vc dummy "$FILE" | \ egrep "^(ID_LENGTH=)" | cut -d '=' -f 2` if [ -z $length ]; then echo "mplayer was unable to get the $FILE length." continue fi SKIP=`echo $length*$SKIPOFFSET/100|bc -l` echo "calcuated skip seconds: $SKIP" # command to get jpeg from video mplayer -noframedrop -ss $SKIP -vo \ jpeg:quality=50:outdir=$OUTPATH -frames 2 $VC -nosound "$FILE" & wait echo mv $OUTPATH/$FRAME $COVERPATH/intid.$ID.jpg # move jpeg from outpath to coverpath if ! mv -f "$OUTPATH/$FRAME" "$COVERPATH/intid.$ID.jpg" ; then echo "Move failed. Will not update videometadata table..." rm -f "$OUTPATH/$FRAME" else # SQL to update table with cover image path UPDATE=`mysql $DB -u $USER \ -e "UPDATE videometadata SET coverfile='$COVERPATH/intid.$ID.jpg' \ WHERE intid=$ID LIMIT 1 ;" -BN` fidone exit 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-users/attachments/20070606/29465df8/attachment-0001.htm
More information about the mythtv-users
mailing list