Full time video recording with vlc
Posted: Mon Mar 03, 2014 11:26 am
I wrote a simple script to use vlc to record video full time. Since I want to have the video in 1 hour pieces I use cron to restart the recording every hour. It also can delete the old files. The rtsp stream path is for a Dahua HFW4300S, but can be replaced for the path of other cameras.
# create filename including date and hour
RECORDFILE=$(date +"%Y-%m-%d-%H")
RECORDFILE="cameraname-$RECORDFILE.mp4"
# save stream for 3599 secords to DIRECTORY which could be /home/user/Videos
cvlc 'rtsp://user:pwd@IPadd:554/cam/realmonitor?channel=1&subtype=0' --sout file/mp4:/DIRECTORY/$RECORDFILE --run-time=3599 vlc://quit
# delete files 15 days old
find /DIRECTORY/ -name "*.mp4" -type f -ctime +15 -delete
This does not decompress or transcode the stream so it records without using much cpu. I am using zoneminder modect on the low definition substream to locate the important events.
# create filename including date and hour
RECORDFILE=$(date +"%Y-%m-%d-%H")
RECORDFILE="cameraname-$RECORDFILE.mp4"
# save stream for 3599 secords to DIRECTORY which could be /home/user/Videos
cvlc 'rtsp://user:pwd@IPadd:554/cam/realmonitor?channel=1&subtype=0' --sout file/mp4:/DIRECTORY/$RECORDFILE --run-time=3599 vlc://quit
# delete files 15 days old
find /DIRECTORY/ -name "*.mp4" -type f -ctime +15 -delete
This does not decompress or transcode the stream so it records without using much cpu. I am using zoneminder modect on the low definition substream to locate the important events.