#!/bin/bash

# TimeLapse snapshot capture script.

# This script should capture any stills in the incoming Stills directory

time=`date '+%Y_%m_%d__%H_%M_%S'`;

# Specific for each camera
CameraName=snapshots
CameraIP='192.168.1.189'

CameraUsername='admin'
CameraPassword='123456'

# Shouldn't need to be changed!
StorageDirectory=./
StorageFilename=blob-$time.png

mkdir -p $StorageDirectory/$CameraName;

ffmpeg -rtsp_transport tcp -i rtsp://$CameraUsername:$CameraPassword@$CameraIP/ch01.264 -ss 00:00:01.50 -vframes 1 $StorageDirectory/$CameraName/$StorageFilename -nostats -hide_banner -v 0 -loglevel quiet;
cp $StorageDirectory/$CameraName/$StorageFilename $StorageDirectory/latest_snapshot.png;
