Created
May 9, 2020 22:34
-
-
Save clement-analogue/24b67f8e1381ec2595a8faae82b25ea0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# find all video files without thumbnail and create thumbnails | |
db="" | |
host="mysql.example.com" | |
user="" | |
pw="" | |
mysql -h $host -P 3306 -D$db -u$user -p$pw -se 'SELECT id,path FROM `piwigo_images` where representative_ext is null and right(file,3) = "mp4"' | while read -r id value; | |
do | |
s=${value##*/} | |
echo "missing for ${value##*/}" | |
path=$(dirname "${value#.}") | |
# this is specific to my installation.. | |
fullpath="/var/www/html/photos${path}/pwg_representative/${s%.*}.png" | |
pathToVideo="/var/www/html/photos${value#.}" | |
echo "will load new thumb ${pathToVideo} and store as ${fullpath}" | |
ffmpeg -i $pathToVideo -ss 00:00:04.000 -vframes 1 $fullpath | |
if [ $? -eq 0 ]; then | |
echo "OK, thumb created" | |
dbquery=$(mysql -h $host -P 3306 -D$db -u$user -p$pw -se 'UPDATE `piwigo_images` SET representative_ext = "png" WHERE id = "'${id}'";') | |
if [ $? -eq 0 ]; then | |
echo "OK, db sync done" | |
else | |
echo "Error" | |
exit 1 | |
fi | |
else | |
echo "Error" | |
exit 1 | |
fi | |
done | |
echo "DONE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment