Hello,
Hand crafting of thumbnails for videos is rather inconvenient and time consuming therefore lots of videos end up not having a thumbnail. Therefore an automatic thumbnail generation capability is thought to be useful.
The enclosed sample implementation adds a Video thumbnail table in date base, and modifies scanner.c and metadata.c files to support thumbnail files for video. Upnpsoap.c and upnphttp.c are also modified to add the new feature. The actual transformation thumbnail extraction is done by means of a external shell script called by the minidlna initialisation procedure on for each video found. This script extracts a jpeg file from video installs it in some cache directory and returns the patch the thumbnail file to the calling minidlna program. Caution name and patch of the script are currently hardcoded in the proposed path.
Sample code for the shell script below.
Bye,
Pbvdl
Hope this is usefull.
path="$1";
id=$2;
# Script for generating minidlna patch video thumbnails
if [ ! -f $path ]; then { exit; }; fi;
CACHEDIR=/var/cache/minidlna/videothumbnail-cache;
PREFIX=thumb_;
LOGFILE=/tmp/videothumbnailout;
if [ -f $path.jpg ]; then {
# if Patch.jpg file exists (e.g. myvideo.avi.jpg) use this file as thumbail
if ( ! exif $path.jpg >> $LOGFILE 2>&1 ); then jhead -mkexif -rgt 160 $path.jpg; fi;
# Check exif header and add one if needed.
file=$path.jpg;
}; else {
# else extract frame 0 from video and copy it to a cache directory.
file=$CACHEDIR/$PREFIX$id.jpg;
if [ ! -d $CACHEDIR ]; then mkdir $CACHEDIR; fi;
if [ -f $file ]; then rm -f $file; fi;
ffmpeg -ss 0 -i "$path" -f image2 -vframes 1 "$file" >> $LOGFILE 2>&1;
jhead -mkexif -rgt160 "$file" >>$LOGFILE 2>&1;
};
fi
echo -n $file
Patch file of sample implemenation