#!/bin/bash
IN="$1" # eg. ./folder/video.mp4
SIZE_W=180
SIZE_H=140
rm -rf ./thumbs
mkdir ./thumbs
echo "processing" > ./thumbs/imgready.log
LN=$(ffprobe -i "$IN" -show_entries format=duration -v quiet -of csv='p=0')
WH=$(ffprobe -i "$IN" -show_streams -v quiet|grep "width\|height" | cut -d = -f 2)
WH=(${WH[0]})
W=${WH[0]}
H=${WH[1]}
#ffmpeg -i "../_files/vid/$IN" -vf "fps=30/$LN,scale=$SIZE_W:$SIZE_H" ./thumbs/img%03d.jpg -y
ASPECT=$(echo "$W/$H" | bc -l)
POS=$(echo "(($SIZE_H*$ASPECT)-$SIZE_W)/2" | bc)
ffmpeg -ss 00:00:00.0 -i "$IN" -vf "fps=30/$LN,scale=-1:$SIZE_H,crop=$SIZE_W:$SIZE_H:$POS:0" ./thumbs/img%03d.jpg -y
echo "ready" > ./thumbs/imgready.log
montage -density 300 -tile 6x5 -geometry +5+5 -border 0 ./thumbs/*.jpg ./thumbs/out.png
exit
Top