-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartStream.sh
executable file
·31 lines (24 loc) · 1.31 KB
/
startStream.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/zsh
# Check if stream is already running (excluding the grep process and consoleout from the result)
ps | grep "gst-launch-1.0" | grep -v grep &> /dev/null
ret=$?
# Stream is not running
if [ $ret -eq 1 ]; then
echo "############################################"
echo "[INFO] STARTING AWS KINESIS VIDEO STREAM!"
echo "############################################"
# Get role stream keys from .env
export $(egrep -v '^#' $PWD/../../.env | xargs)
# Start streaming to aws in background, squashing all debug as we make our own
gst-launch-1.0 --quiet avfvideosrc device-index=0 ! videoconvert ! video/x-raw,format=I420,width=640,height=480,framerate=20/1 ! x264enc bframes=0 key-int-max=65 bitrate=300 ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink stream-name="CameraVideoStream" storage-size=512 access-key="${ACCESS_KEY}" secret-key="${SECRET_KEY}" aws-region="eu-west-1" > "${ROOT_DIR}/src/scripts/stream.log" > /dev/null 2>&1 &
echo "[SUCCESS] Stream is running!"
exit 0
# Stream is already running
elif [ $ret -eq 0 ]; then
echo "[SUCCESS] Stream is already running! Exiting..."
exit 0
# Something went wrong with ps or grep
else
echo "[ERROR] Unable to determine if stream exists. Something went wrong with the searching logic itself"
exit $ret
fi