Setup cams

Following steps you must do for each cam you have to setup. I describe it on the example of my Foxcam cam. Other manufactures may be slightly different.

  • Connect the IP camera
  • Find IP address of the camera
  • Setup Port Forwarding
  • Configure DynDNS
  • Setup folders and FTP user on the server
  • Configure IP cam user/settings

Connect the IP camera

Connecting the IP camera is is very easy. Just plugin the RJ45 network cable to the home router (e.g. my FritzBox) and the power supply. In some cams you can use WLAN connection instead but this is not what I would prefer.

Find the IP address of the camera

Now look in your rooter for the IP address assigned to the cam by DHCP which is enabled by default. You can access the cam from your home network in the web browser by the IP address like http://192.168.1.23. You can also assign a network name to the IP address and access the cam from the home network like http://ipcam1. So you have not to remember all the IP addresses. The MJPEG stream of the cam can be easily viewed now at http://ipcam1/videostream.cgi.

Setup port forwarding

For uploading images to the server the cam doesn’t need port forwarding. But for accessing the MJPEG from the server we have to forward the port 80 of the cam to outside of the home network. This can be done in the home router configuration. Lets forward the port 80 to port 1111 on ipcam1. Each cam in your network has to get its own external port number. In order the port forwarding is working reliably let your ipcam always get the same internal IP address (enable the option “Assign the same IP address to a device” on the router or disable “Obtain IP from DHCP Server” on the cam and set the IP address manually). Now your MJPEG stream can be accessed from everywhere at http://your_external_ip:1111/videostream.cgi.

Configure DynDNS

In order not to handle with your external IP address which may change every night or even more frequently you have to setup the DynDNS. This can be done at www.dyndns.org where your get your dynamic hostname like mynick.dyndns.org. Then you setup your home router for DynDNS. It’s possible to setup DynDNS in the cam but I prefer to use the router configuration. Now your MJPEG stream can be found at http://mynick.dyndns.org:1111/videostream.cgi.

Setup folders and FTP user on the server

For each cam we have to create a different FTP user as the script is watching the FTP log for specific username is logging in (and triggers the recording for that specific ipcam). With proftpd installed we can create an FTP user ipcam1 like this:

useradd -d /var/ip-cam -s /bin/false ipcam1 -g ftpuser
passwd ipcam1

Then we need some folders on the server for this user. You can use different folder names and adjust the paths in the script configuration.

mkdir /var/ip-cam/cam1     # FTP upload for pictures
mkdir /var/ip-cam/ipcam1   # MP4 records from MJPEG stream
mkdir /root/ip-cam/cam1    # Final daily MP4 from pictures
mkdir /root/ip-cam/ipcam1  # Final daily MP4 from MJPEG stream

chown ipcam1:ftpuser /var/ip-cam/cam1
chmod 775 /var/ip-cam/cam1

Configure IP cam user/settings

Now go to the admin interface of you ipcam at http://ipcam1 and do following things:

  • Change the admin user password.
  • Create additional user stream (Group: Visitor, means it may only view the cam) with a good password. This user will be used when accessing the MJPEG stream from the server like http://stream:pass@mynick.dyndns.org/videostream.cgi
  • Setup FTP server access.
    • FTP server: yourserver.tld
    • FTP port: 21
    • FTP user: ipcam1
    • FTP password: password you specified for ipcam1
    • FTP upload folder: /cam1
    • FTP mode: PASV
  • Test FTP server access (Button “Test”). It must be working now.
  • Setup motion detection (Alarm Service Settings).
    • Motion Detection Armed: on
    • Motion Detect Sensibility: 10 (highest sensibility, if you get to many detections try a lower value)
    • Upload Image on Alarm: on
    • Upload Interval (Seconds): 20 (it’s enough to trigger the recording and keep it running)

Ready. Now you cam is running. It’s uploading images via FTP on motion detection. And the MJPEG stream can be accessed from the server.