From: paul Date: Sat, 22 Aug 2015 16:03:51 +0000 (+0000) Subject: stop mplayer helpers from consuming stdin, remove dependency on `at` X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=f5de72a64ced97eda77921bd3207a17a5e9a28f5;p=serve0 stop mplayer helpers from consuming stdin, remove dependency on `at` svn path=/trunk/; revision=85 --- diff --git a/helpers/genmeta.sh b/helpers/genmeta.sh index 4fa28e4..77d3ebf 100755 --- a/helpers/genmeta.sh +++ b/helpers/genmeta.sh @@ -8,7 +8,7 @@ if [ -r "$meta" ]; then description="$(sed -n '3,$p' "$meta")" fi -mplayer --input=nodefault-bindings:conf=/dev/null -nosound -vo null -identify -frames 0 "$video" \ +echo '' |mplayer --input=nodefault-bindings -nosound -vo null -identify -frames 0 "$video" \ | sort \ | sed -rn 's:ID_LENGTH=(.*)(\..*)$:\1:p; s:ID_VIDEO_HEIGHT=(.*):\1:p; diff --git a/helpers/genthumb.sh b/helpers/genthumb.sh index b481bd5..7db8478 100755 --- a/helpers/genthumb.sh +++ b/helpers/genthumb.sh @@ -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}" diff --git a/pages/common.sh b/pages/common.sh index e03e6f5..6b597d5 100755 --- a/pages/common.sh +++ b/pages/common.sh @@ -40,11 +40,18 @@ taglist=$( ) genthumb(){ - videofile="$(printf %s "$1" |sed -r "s;';'\\'';g")" - thumb="$(printf %s "$2" |sed -r "s;';'\\'';g")" + videofile="$1" + thumb="$2" - printf '%s\n' "${_EXEC}/helpers/genthumb.sh '$videofile' '$thumb' >/dev/null 2>/dev/null" \ - | batch + nohup nice -10 "${_EXEC}"/helpers/genthumb.sh "$videofile" "$thumb" >/dev/null 2>/dev/null & + #printf '%s\n' "${_EXEC}/helpers/genthumb.sh '$videofile' '$thumb' >/dev/null 2>/dev/null" \ + #| batch +} +genmeta(){ + videofile="$1" + meta="$2" + + "${_EXEC}"/helpers/genmeta.sh "$videofile" "$meta" >/dev/null } _printVideo(){ @@ -58,7 +65,7 @@ _printVideo(){ videofile="${_DATA}/videos/$info" thumb="${_DATA}/thumbs/${info}.jpg" [ -r "$thumb" ] || genthumb "$videofile" "$thumb" - [ -r "$meta" ] || "${_EXEC}/helpers/genmeta.sh" "$videofile" "$meta" >/dev/null + [ -r "$meta" ] || genmeta "$videofile" "$meta" head -n1 "$meta" |read length width height filename [ -z "$length" ] && length=0