Last active
June 17, 2021 19:56
-
-
Save LucaTNT/d226ac78d442f32e1a38 to your computer and use it in GitHub Desktop.
Record Foscam IP camera live feed
This file contains 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 | |
# recordCam.sh | |
# ------------ | |
# This script saves the live video from the Foscam IP camera to a full-quality mp4 file. | |
# I chose to split the files every 15 minutes (900 seconds), to quickly find the time I need. | |
# Note: audio is not saved as my cameras don't have a microphone connected to them. | |
# ----------- | |
# Author: @LucaTNT | |
# License: BSD | |
# Uncomment this line if you're having trouble with zero-sized files (tipically happens on low end cameras), thanks Eric! (https://lucatnt.com/2014/08/record-and-archive-video-from-ip-cameras/#comment-48019) | |
# killall -INT ffmpeg | |
# The file name. I use the date to make finding files easier. | |
name="`date +%Y-%m-%d_%H.%M`" | |
# Where the videos will be saved | |
BASEpath='/path/to/surveillance/folder' | |
RECpath=$BASEpath'/video' | |
# Save the streams using ffmpeg at 30 fps, stopping the capture after 900 seconds (15 minutes). Add more lines if you have more than 2 cameras | |
ffmpeg -i rtsp://username:[email protected]:80/videoMain -r 30 -vcodec copy -an -t 900 $RECpath/cam01/$name.mp4 </dev/null >/dev/null 2>/tmp/cam01.log & | |
ffmpeg -i rtsp://username:[email protected]:80/videoMain -r 30 -vcodec copy -an -t 900 $RECpath/cam02/$name.mp4 </dev/null >/dev/null 2>/tmp/cam02.log & |
You could compress by replacing -vcodec copy
with -vcodec x264 -vb 500k
(where 500k is your desired bitrate), but keep in mind this will stress your CPU way harder than just saving the stream as is.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great script -
this fills up my hard drive within a day or so which compression command do you suggest ?