summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-05 14:45:11 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-05 14:45:11 +0200
commit75055e126e10f074516a2be67f901472af98803a (patch)
treeca093f3c1404c58b274f3c3083645388d68bfab9 /bin
parent8e878f219d7485bfc0dba17c59960788d0df9115 (diff)
Fix avoid unbound variables.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/stream19
1 files changed, 12 insertions, 7 deletions
diff --git a/bin/stream b/bin/stream
index 452f47e..4b2f3e7 100755
--- a/bin/stream
+++ b/bin/stream
@@ -1,6 +1,6 @@
#!/bin/sh
-set -e
+set -eu
# TODO: Externalize to site-specific configfile
[ $# -gt 0 ] || set -- morla 5002 -- dvcam ../../content/icon_small.png
@@ -15,9 +15,9 @@ while [ $# -gt 0 ]; do
--)
shift; break;;
*)
- if [ -z "$HOST" ]; then
+ if [ -z "${HOST:-}" ]; then
HOST=$1
- elif [ -z "$FIRSTPORT" ]; then
+ elif [ -z "${FIRSTPORT:-}" ]; then
FIRSTPORT=$1
else
exit1 "Too many arguments: Max. 2 about target"
@@ -30,6 +30,10 @@ done
# TODO: Externalize to site-specific configfile
[ $# -gt 0 ] || set -- dvcam ../../content/icon_small.png
+AINPUT=
+VINPUT=
+WINPUT=
+XINPUT=
while [ $# -gt 0 ]; do
case $1 in
alsa=*) ALSA=${1#*=}; AINPUT=$((AINPUT+1));;
@@ -62,8 +66,8 @@ fi
[ -z "$VINPUT" ] || [ $VINPUT -eq 1 ] || exit1 "Too many arguments: Max. 1 video source"
[ -z "$WINPUT" ] || [ $WINPUT -eq 1 ] || exit1 "Too many arguments: Max. 1 watermark source"
[ -z "$XINPUT" ] || [ $XINPUT -eq 1 ] || exit1 "Too many arguments: Max. 1 multimedia source"
-[ -n "$NOAUDIO" ] || [ -z "$AINPUT$XINPUT" ] || HASAUDIO=1
-[ -n "$NOVIDEO" ] || [ -z "$VINPUT$XINPUT" ] || HASVIDEO=1
+[ -n "${NOAUDIO:-}" ] || [ -z "$AINPUT$XINPUT" ] || HASAUDIO=1
+[ -n "${NOVIDEO:-}" ] || [ -z "$VINPUT$XINPUT" ] || HASVIDEO=1
[ "$AINPUT$VINPUT$XINPUT" = "1" ] || TWOSOURCES=1
VSTREAMINDEX=1
[ -n "$AINPUT" ] || VSTREAMINDEX=0
@@ -83,11 +87,12 @@ height=$HEIGHT
MKWEBM="[v${height}webm]"
MKMPEG="[v${height}mpeg]"
+VCODECCOUNT=
[ -z "$MKWEBM" ] || VCODECCOUNT=$((VCODECCOUNT+1))
[ -z "$MKMPEG" ] || VCODECCOUNT=$((VCODECCOUNT+1))
-SAVESTEM="$SAVEDIR/$(date +%Y%m%d-%H%M%S)"
-${SAVEDIR:+export FFREPORT=file="$SAVESTEM.log"}
+[ -z "${SAVEDIR:-}" ] || SAVESTEM="${SAVEDIR:-}/$(date +%Y%m%d-%H%M%S)"
+[ -z "${SAVEDIR:-}" ] || export FFREPORT=file="$SAVESTEM.log"
# * scale+watermark trick based on http://stackoverflow.com/a/10937357
# * routing based on http://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs#Teepseudo-muxer