Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Record Foscam IP camera live feed
# ------------
# 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! (
# 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
# 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:password@ -r 30 -vcodec copy -an -t 900 $RECpath/cam01/$name.mp4 </dev/null >/dev/null 2>/tmp/cam01.log &
ffmpeg -i rtsp://username:password@ -r 30 -vcodec copy -an -t 900 $RECpath/cam02/$name.mp4 </dev/null >/dev/null 2>/tmp/cam02.log &

This comment has been minimized.

Copy link

@putout putout commented Jan 25, 2021

Great script -

this fills up my hard drive within a day or so which compression command do you suggest ?


This comment has been minimized.

Copy link
Owner Author

@LucaTNT LucaTNT commented Jan 25, 2021

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