Synology DiskStation DSM update 7.2.2 broke support for HEIC and video thumbnails such as HVEC.
This guide will help you setting up a scheduled task using filebot to generate the missing thumbnails in the background for File Station for the web and DS File on mobile.
Log into DSM.
You first need to add third party package sources:
- Package Center ► Settings ► Package Sources ► Add ► Name:
FileBotand Location:https://get.filebot.net/syno/ - Package Center ► Settings ► Package Sources ► Add ► Name:
SynoCommunityand Location:https://packages.synocommunity.com/
Then, install the following packages:
- Package Center ► Community ► Install Java Installer package
- Package Center ► Community ► Install FileBot package
- Package Center ► Community ► Install FFmpeg 7 package
- Package Center ► Community ► Install ImageMagick package
For the rest of the process, you'll need to enable SSH access on your Synology NAS:
- Control Panel ► Terminal & SNMP ► Terminal tab ► Check Enable SSH service, choose the port number you like (
22) then click "Apply".
You can now connect to your Synology NAS using SSH as an administrator using the ssh your_username@synology_ip command on macOS and Linux or using any ssh client such as PuTTY on Windows.
- Make a
scriptsfolder in yourhomefolder. - Create the
generate-photo-thumbnails.shscript file with the following content (replace the value ofPHOTO_FOLDERby your photo folder if it's different):
#!/bin/bash
# Change this value with the location of your photo folder
PHOTO_FOLDER='/volume1/photo'
# Use flock to prevent multiple instances
LOCKFILE="/tmp/$(basename $0).lock"
exec 200>"$LOCKFILE"
flock -n 200 || {
echo "Another instance of the script is already running."
exit 0
}
# Use the folder provided as argument. Otherwise, use PHOTO_FOLDER.
FOLDER_PATH="${1:-$PHOTO_FOLDER}"
echo "Generating thumbnails for ${FOLDER_PATH}"
# Generate HEIC photos thumbnails
filebot -find "$FOLDER_PATH" --filter 'def i = f.dir / "@eaDir" / f.name / "SYNOFILE_THUMB_M.jpg"; ext ==~ /(?i:HEIC|HEIF)/ && !i.exists() && (i.dir.exists() || i.dir.mkdirs())' \
-exec /usr/local/bin/magick '{f}' -thumbnail '360x448>' -write '{folder}/@eaDir/{f.name}/SYNOFILE_THUMB_M.jpg' -thumbnail '120x160>' '{folder}/@eaDir/{f.name}/SYNOFILE_THUMB_S.jpg'
# Generate video thumbnails
filebot -find "$FOLDER_PATH" --filter 'def i = f.dir / "@eaDir" / f.name / "SYNOVIDEO_VIDEO_SCREENSHOT.jpg"; f.video && (i.dir.exists() || i.dir.mkdirs()) && !i.exists() && seconds > 0' \
-exec /usr/local/bin/ffmpeg7 -hide_banner -loglevel error -an -ss '{seconds/5}' -i '{f}' -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y '{folder}/@eaDir/{f.name}/SYNOVIDEO_VIDEO_SCREENSHOT.jpg'It's better to make sure the script actually works before adding it as a scheduled task.
You can run the script on a specific folder by typing the following command: bash ~/scripts/generate-photo-thumbnails.sh "/volume1/photo/some_pictures_folder"
The process may take several minutes and even hours depending on the amount of files you have to process.
You may also want to run the script on demand right after uploading a new folder.
Please be aware that the script is CPU intensive, it's why it's not possible to run several instances of the script at the same time.
If everything is fine (you should see the thumbnails in the folder in DSM) you proceed to the next step.
- Log into your Synology using SSH.
- Go to your home folder by typing:
cd ~ - Get the full path of your home folder by typing
pwd(you'll get something such as/var/services/homes/your_username). - Log into DSM.
- Control Panel ► Task Scheduler ► Create ► Scheduled Task ► User defined-script.
- Under the "General Settings" tab, set "Task" to
Generate photo thumbnailsand set "User" with your username. - Under the "Schedule" tab, check "Run on the following days" and set "Repeat" to "Daily". Under "Time", select a "Start time" somewhere in the middle of the night (ie 4am).
- Under the "Task Settings" tab, set the "User-defined script" to
bash /var/services/homes/your_username/scripts/generate-photo-thumbnails.sh(refer to the returned value at step 3). - Click "OK".
If
dockeris installed then you could make it work without any additional dependencies (other than docker) so that it boils down to copy & pasting some code into theTask Managerlike in this example:https://www.filebot.net/forums/viewtopic.php?t=14245#task-scheduler
On second thought, DSM does require you to be
rootto rundockerand teaching people to blindly copy & paste code and then run it asrootmight not be such a good idea. Writing your own scripts and understanding the code is always a good idea.