Canada  united states of america usa  linkedinfacebook   Call Us Today: 866.646.6461

Your Dedicated IT Experts

ALT is an IT Support and IT Consulting firm for all business technology needs, with offices in Ottawa, Miami, Philadelphia and Syracuse. Our team of technicians and consultants have the expertise spanning today’s best-in-class technologies, which will allow your organization to lower cost, increase agility, improve efficiency, and succeed in today’s competitive markets.

A small script to capture video stream (eg: from a security camera). The script takes in time in format of HH:MM:SS and created directories based on the current date. Based on the current variables, it outputs the files to /opt/camera/recordings/. It also needs a temp directory, called streams under /opt/camera/.

Usage example (to capture 11 minutes of the stream):
capture.sh 00:11:00

#!/bin/bash
STREAM="rtsp://172.16.0.25:554/play2.sdp"
FILE="cam"
TIME=$1 # in 00:00:00 format
OUT=$FILE-`date '+%m-%d-%y_%H_%M'`
CWD=/opt/camera
DATE=`date '+%m-%d-%y'`
if [ ! -d $CWD/streams]
then
mkdir -p $CWD/streams
fi
ffmpeg -i "$STREAM" -t $TIME -c copy -an $CWD/streams/$OUT.mkv
if [ ! -d $CWD/recordings/$DATE ]
then
mkdir -p $CWD/recordings/$DATE
fi
mv $CWD/streams/$OUT.mkv $CWD/recordings/$DATE/$OUT.mkv

If you need help with your IT projects, fee free to contact us for IT support. Our consultants will be more than happy to help.

Last updated Dec 2, 2018