Created
April 15, 2020 21:38
-
-
Save georg90/9f653c090afd54f67d1ad70f03c6e0bb to your computer and use it in GitHub Desktop.
Create thumbnails for videos in piwigo remotely if webspace doesn't allow the install of ffmpeg etc.
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 remotely (I have a nodered API that can receive the video file and return the thumbnail) | |
# I run this as a cronjob every day | |
db="" | |
host="" | |
user="" | |
pw="" | |
remote_ffmpeg="" | |
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="/piwigo${path}/pwg_representative/${s%.*}.png" | |
pathToVideo="/piwigo${value#.}" | |
echo "will load new thumb ${pathToVideo} and store as ${fullpath}" | |
/usr/bin/curl -o $fullpath --user "user:pass" -X POST -F "filedata=@${pathToVideo}" $remote_ffmpeg | |
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" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment