Skip to content

Instantly share code, notes, and snippets.

@bytepossum
Created September 5, 2015 14:14
Show Gist options
  • Save bytepossum/be5d4fdfc2a5f08fbc91 to your computer and use it in GitHub Desktop.
Save bytepossum/be5d4fdfc2a5f08fbc91 to your computer and use it in GitHub Desktop.
Bash script to start RTSP recording
#!/bin/bash
VOPATH=/media/data/motion # video output directory
MPATH=/home/pi/motion # motion log directory
FFMPEG=/usr/local/bin/ffmpeg # path to ffmpeg
CAM=1
pidfile=$MPATH/cam$CAM.pid
if [ ! -f $pidfile ]; then
echo "PID file not found."
else
echo "PID file exists, killing stale process."
read pid < $pidfile
echo "Sending SIGINT to process $pid."
kill -INT $pid
echo "Removing PID file $pidfile."
rm $pidfile
fi
filename=$VOPATH/$(date +%F_%R)_$CAM.mp4
echo "Saving to $filename..."
# $FFMPEG -rtsp_transport tcp -i rtsp://192.168.0.1:554/user=user_password=password_channel=1_stream=0.sdp -c copy $filename &
openRTSP -b 250000 -4 rtsp://192.168.0.1:554/user=user_password=password_channel=1_stream=0.sdp >$filename &
pid=$!
echo "Started recording process with PID $pid..."
echo $pid > $pidfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment