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

# 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.
info=$(ffprobe "$1" -show_format 2>&1)
seconds=${info#*duration=}; seconds=${seconds%%.*}
exec ffmpeg -ss $((seconds / 2)) -i "$1" -vframes 1 -filter:v scale="$3:-1" "$2" 2>/dev/null
