Created
July 20, 2018 22:01
-
-
Save Franco-Poveda/3e786bac23877cfe946ddcf63e10294f to your computer and use it in GitHub Desktop.
get and encode a frame from each element in a array of RTSP hosts, saves output to .jpg file using the last ip octet and timestamp to generate names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a hosts=( | |
"192.168.0.21" | |
"192.168.0.22" | |
"192.168.0.23" | |
"192.168.0.24" | |
) | |
user="user" | |
pwd="password" | |
path="/home/user/snaps/" | |
if ! [ -x "$(command -v /usr/bin/avconv)" ]; then | |
echo 'Error: avconv is not installed.' >&2 | |
exit 1 | |
else | |
for i in "${hosts[@]}" | |
do | |
cam=$(echo $i| cut -d'.' -f 4) | |
timestamp=$(date +"%T") | |
/usr/bin/avconv -rtsp_transport tcp -i rtsp://"$user":"$pwd"@"$i":554 -r 1 -vsync 1 -qscale 1 -frames 1 -f image2 "$path"cam"$cam"."$timestamp".jpg | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment