2 # Copyright 2014 - 2016 Paul Hänsch
4 # This file is part of Serve0
6 # Serve0 is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Serve0 is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Serve0 If not, see <http://www.gnu.org/licenses/>.
22 if [ -e "$video" -a \! -e "$thumb" ]; then
23 printf '' |mplayer -input nodefault-bindings -nosound -vo null -frames 0 -identify "$video" \
25 | sed -rn 's:^.*ID_LENGTH=(.*)(\..*)$:\1:p;
26 s:^.*ID_VIDEO_HEIGHT=(.*)$:\1:p;
27 s:^.*ID_VIDEO_WIDTH=(.*)$:\1:p;' \
29 | read length height width 2>/dev/null
31 [ "$(($height * 1000 / $width))" -gt "750" ] && width="$((75 * $width / $height))" \
33 [ -z $width ] && width=100
34 chunk="$((${length:-0} / 5))"
37 for cnt in 1 2 3 4; do
38 printf '' |mplayer -input nodefault-bindings -nosound -vo jpeg:outdir="$tmp" -frames 1 \
39 -benchmark -vf framestep=I,scale="$width":-2 -ss "$(($cnt*$chunk))" "$video" >/dev/null 2>/dev/null
40 mv "$tmp/00000001.jpg" "${tmp}/_${cnt}.jpg"
42 montage "${tmp}"/_[1234].jpg -tile 2x2+0+0 -geometry 100x75+3+3 -background '#000000' "${thumb}" 2>/dev/null