#!/bin/dash
# $1-path to source, $2-path to output, $3-pixel size

# remove option -f to disable film strip overlay
exec > /dev/null 2>&1  # silence everything
type ffmpegthumbnailer && 
exec ffmpegthumbnailer -i"$1" -o"$2" -s$3 -t50 -m -M -f

### Fatdog64-814 legacy thumbnailer
# note: ffmpeg has -vf "thumbnail" filter,  but Jake said it often returns
# blank frames. "-ss" takes the video from somewhere in the middle of the video.
seconds=0 info=$(ffprobe "$1" -show_format 2>&1)
case "$info" in *duration=) seconds=${info#*duration=}; seconds=${seconds%%.*} ;; esac
exec ffmpeg -loglevel 16 -y -ss $((seconds / 2)) -i "$1" -frames:v 1 -filter:v scale="$3:-1" "$2"
