#!/bin/zsh
+# Copyright 2014 - 2017 Paul Hänsch
+#
+# This file is part of Serve0
+#
+# Serve0 is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Serve0 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Serve0 If not, see <http://www.gnu.org/licenses/>.
video="$1"
thumb="$2"
if [ -e "$video" -a \! -e "$thumb" ]; then
- echo '' |mplayer -input nodefault-bindings -nosound -vo null -frames 0 -identify "$video" \
+ printf '' |mplayer -input nodefault-bindings -nosound -vo null -frames 0 -identify "$video" \
| sort \
| sed -rn 's:^.*ID_LENGTH=(.*)(\..*)$:\1:p;
s:^.*ID_VIDEO_HEIGHT=(.*)$:\1:p;
tmp="$(mktemp -d)"
for cnt in 1 2 3 4; do
- echo '' |mplayer -input nodefault-bindings -nosound -vo jpeg:outdir="$tmp" -frames 1 \
+ printf '' |mplayer -input nodefault-bindings -nosound -vo jpeg:outdir="$tmp" -frames 1 \
-benchmark -vf framestep=I,scale="$width":-2 -ss "$(($cnt*$chunk))" "$video" >/dev/null 2>/dev/null
mv "$tmp/00000001.jpg" "${tmp}/_${cnt}.jpg"
done
- montage "${tmp}"/_[1234].jpg -tile 2x2+0+0 -geometry 100x75+3+3 -background '#000000' "${thumb}" 2>/dev/null
+ montage "${tmp}"/_[1234].jpg -tile 2x2+0+0 -geometry 100x75+3+3 -background '#000000' -quality 50 "${thumb}" 2>/dev/null
rm -r "${tmp}"
fi