Multimedia Console and video files
Multimedia Console generates thumbnails for image files but does not generate thumbnails for video files (1, 2, 3, 4, 5, 6) for some reason.


Console Output: Select all
$ find /share/Multimedia/Movies/ -type f
/share/Multimedia/Movies/.@__thumb/s800The Man from Earth (2007).mkv
/share/Multimedia/Movies/.@__thumb/s100The Man from Earth (2007).mkv
/share/Multimedia/Movies/.@__thumb/defaultThe Man from Earth (2007).mkv
/share/Multimedia/Movies/The Man from Earth (2007).mkv
$ find /share/CACHEDEV1_DATA/.system/thumbnail/ -type f
/share/CACHEDEV1_DATA/.system/thumbnail/201/1.jpg
/share/CACHEDEV1_DATA/.system/thumbnail/201/1-1.jpg
/share/CACHEDEV1_DATA/.system/thumbnail/201/1-2.jpg
Generate thumbnails for video files
The following docker command uses filebot with -exec to execute ffmpeg for each video file to generate the missing thumbnail files:Shell: Select all
SHARE='/share/Multimedia/Movies'
docker run --rm -it -e PUID=0 -e PGID=0 -v "data:/data" -v "$SHARE:$SHARE" rednoah/filebot \
-find "$SHARE" --filter 'def i = f.dir / ".@__thumb" / "default$f.name"; f.video && i.dir.exists() && !i.exists()' \
-exec sh -xc 'ffmpeg -an -ss {quote seconds/5} -i {quote f} -vframes 1 -vf scale=800:800:force_original_aspect_ratio=increase -f mjpeg -y {quote folder}/.@__thumb/s800{quote f.name} \
&& ffmpeg -i {quote folder}/.@__thumb/s800{quote f.name} -vf scale=260:260:force_original_aspect_ratio=decrease -f mjpeg -y {quote folder}/.@__thumb/s100{quote f.name} \
&& ffmpeg -i {quote folder}/.@__thumb/s800{quote f.name} -vf scale=400:400:force_original_aspect_ratio=increase -f mjpeg -y {quote folder}/.@__thumb/default{quote f.name} \
&& touch -r {quote f} {quote folder}/.@__thumb/s800{quote f.name} {quote folder}/.@__thumb/s100{quote f.name} {quote folder}/.@__thumb/default{quote f.name}'


Generate thumbnail index
After generating thumbnails for each video file in the .@__thumb folder, we then need to prepare the .system/thumbnail index to make thumbnails available to DLNA Media Server and Media Streaming Add-on as well. The regenerate-thumbnail-index.sh script will take care of that:Shell: Select all
sudo /opt/filebot/bin/regenerate-thumbnail-index.sh
Shell: Select all
#!/bin/sh -xu
SYSTEM_VOLUME="$(getcfg SHARE_DEF defVolMP -f /etc/config/def_share.info)"
function database {
"$SYSTEM_VOLUME/.qpkg/MultimediaConsole/mariadb10/bin/mariadb" --socket=/tmp/mariadb10_mmc.sock --user=root --password=qnapqnap --database s01 --batch --default-character-set=utf8mb4 --execute "$1" --skip-column-names
}
function thumbnail {
[ ! -f "$1" ] || [ "$1" -ef "$2/$3" ] || (mkdir -m 777 -p "$2" && ln -svf "$1" "$2/$3")
}
database 'SELECT v.iVideoId, d.cFullPath, v.cFileName FROM videoTable v INNER JOIN dirTable d ON v.iDirId = d.iDirId' | \
while IFS=$'\t' read -r iVideoId cFullPath cFileName
do
__thumb="/share/$cFullPath.@__thumb"
__shard="$SYSTEM_VOLUME/.system/thumbnail/2$(printf "%02x" "$iVideoId" | tail -c 2)"
thumbnail "$__thumb/s800$cFileName" "$__shard" "$iVideoId.jpg"
thumbnail "$__thumb/default$cFileName" "$__shard" "$iVideoId-1.jpg"
thumbnail "$__thumb/s100$cFileName" "$__shard" "$iVideoId-2.jpg"
done
Generate thumbnails from movie posters
Fetch the movie poster for each movie file (see xattr metadata) to generate the thumbnail files:Shell: Select all
filebot -find "/volume1/Media/Movies" --apply thumbnail

Delete thumbnails for video files
Find and delete the .@__thumb/s* and .@__thumb/default* thumbnail files:Shell: Select all
find "/share/Multimedia/Movies" -type f '(' -path '*/.@__thumb/s[18]00*' -or -path '*/.@__thumb/default*' ')' -print -delete