]> git.plutz.net Git - serve0/blobdiff - helpers/genthumb.sh
stop mplayer helpers from consuming stdin, remove dependency on `at`
[serve0] / helpers / genthumb.sh
index b481bd5d01c01bdfe6a64f356bdd86b258c7a10f..7db84782c82165d5d8b1da48b35706c50148ed12 100755 (executable)
@@ -4,23 +4,23 @@ video="$1"
 thumb="$2"
 
 if [ -e "$video" -a \! -e "$thumb" ]; then
-  mplayer --input=nodefault-bindings:conf=/dev/null -nosound -vo null -frames 0 -identify "$video" \
+  echo '' |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;
-             s:ID_VIDEO_WIDTH=(.*):\1:p;' \
+  | sed -rn 's:^.*ID_LENGTH=(.*)(\..*)$:\1:p;
+             s:^.*ID_VIDEO_HEIGHT=(.*)$:\1:p;
+             s:^.*ID_VIDEO_WIDTH=(.*)$:\1:p;' \
   | tr '\n' ' ' \
   | read length height width
   
-  [ "$(($height*1000/$width))" -gt "750" ] && width="$((75*$width/$height))" \
+  [ "$(($height * 1000 / $width))" -gt "750" ] && width="$((75 * $width / $height))" \
                                            || width=100
   [ -z $width ] && width=100
   chunk="$((${length:-0} / 5))"
   
   tmp="$(mktemp -d)"
   for cnt in 1 2 3 4; do
-    mplayer --input=nodefault-bindings:conf=/dev/null -nosound -vo jpeg:outdir="$tmp" -frames 1 \
-            --benchmark -vf framestep=I,scale="$width":-2 -ss "$(($cnt*$chunk))" "$video"
+    echo '' |mplayer --input=nodefault-bindings -nosound -vo jpeg:outdir="$tmp" -frames 1 \
+             --benchmark -vf framestep=I,scale="$width":-2 -ss "$(($cnt*$chunk))" "$video"
     mv "$tmp/00000001.jpg" "${tmp}/_${cnt}.jpg"
   done
   montage "${tmp}"/_[1234].jpg -tile 2x2+0+0 -geometry 100x75+3+3 -background '#000000' "${thumb}"