Generate thumbnails for video files on Synology NAS

Support for Synology NAS, QNAP NAS and other Embedded Linux systems
Post Reply
User avatar
rednoah
The Source
Posts: 23403
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Generate thumbnails for video files on Synology NAS

Post by rednoah »

Media Indexing and video files

Media Indexing generates thumbnails for image files but does not generate thumbnails for video files (1, 2, 3) for some reason.


:!: File Station, DS File, Media Server and friends therefore cannot display thumbnails for video files:
Screenshot



:idea: Video Station does however generate thumbnails and those thumbnails are then available to File Station, DS File, Media Server and friends, even if the Video Station package is no longer installed. Looks like Video Station is simply using ffmpeg to generate a SYNOVIDEO_VIDEO_SCREENSHOT.jpg file in the @eaDir folder for each video file:

Console Output: Select all

$ while true; do ps -aefyl | grep ffmpeg | grep -v grep; sleep 0.1; done
/var/packages/CodecPack/target/bin/ffmpeg41 -timelimit 20 -an -ss 300 -i '/volume1/Media/Movies/The Man from Earth (2007).mkv' -vframes 1 -vf scale=size=hd480:force_original_aspect_ratio=decrease -f mjpeg -y '/volume1/Media/Movies/@eaDir/The Man from Earth (2007).mkv/SYNOVIDEO_TEMP.jpg'
$ find @eaDir
@eaDir/The Man from Earth (2007).mkv
@eaDir/The Man from Earth (2007).mkv/SYNOINDEX_MEDIA_INFO
@eaDir/The Man from Earth (2007).mkv/SYNOVIDEO_VIDEO_SCREENSHOT.jpg





Generate thumbnails for video files

The following filebot command uses -exec to execute ffmpeg for each video file to generate the missing thumbnail files:
** if the built-in ffmpeg does not work then you may need to use the /var/packages/CodecPack/target/bin/ffmpeg41 binary from the Advanced Media Extensions package

Shell: Select all

filebot -find "/volume1/Media/Movies" --filter 'def i = f.dir / "@eaDir" / f.name / "SYNOVIDEO_VIDEO_SCREENSHOT.jpg"; f.video && i.dir.exists() && !i.exists()' \
	-exec /var/packages/CodecPack/target/bin/ffmpeg41 -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'
Screenshot

:idea: Alternatively, you can use docker to run filebot and full-featured ffmpeg inside a container:

Shell: Select all

sudo docker run --rm -it -e PUID=0 -e PGID=0 -v "data:/data" -v "/volume1:/volume1" rednoah/filebot \
	-find "/volume1/Media/Movies" --filter 'def i = f.dir / "@eaDir" / f.name / "SYNOVIDEO_VIDEO_SCREENSHOT.jpg"; f.video && i.dir.exists() && !i.exists()' \
		-exec ffmpeg -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'




Task Scheduler

You can use Task Scheduler to generate video thumbnails automatically on a schedule:

Shell: Select all

SHARE='/volume1/Media'

docker run --rm -e PUID=0 -e PGID=0 -v 'data:/data' -v "$SHARE:$SHARE" rednoah/filebot \
	-find "$SHARE" --filter 'def i = f.dir / "@eaDir" / f.name / "SYNOVIDEO_VIDEO_SCREENSHOT.jpg"; f.video && !i.exists() && (i.dir.exists() || i.dir.mkdirs())' \
		-exec ffmpeg -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'
ScreenshotScreenshot





Generate thumbnails from movie posters

Fetch the movie / episode poster for each movie / episode file (see xattr metadata) and save it as SYNOVIDEO_VIDEO_SCREENSHOT.jpg file:

Shell: Select all

filebot -find "/volume1/Media/Movies" --apply thumbnail
Screenshot





Delete thumbnails for video files

Find and delete SYNOVIDEO_VIDEO_SCREENSHOT.jpg and SYNOVIDEO_VIDEO_SCREENSHOT_JPEGTN.jpg files:

Shell: Select all

find "/volume1/Media/Movies" -name 'SYNOVIDEO_VIDEO_SCREENSHOT*.jpg' -print -delete
:idea: Please read the FAQ and How to Request Help.
Post Reply