intro

Most of the modern IP Cameras have the option to upload pictures to a FTP server.

Since some settings and naming convention depends on manufacture name, model and even firmware, we will guide you with some basic configurations and rules to properly install and configure your cameras to a FTP server, in our case running a Raspberry running Centos7 as the Operating System.

1. server side

rpm -q --quiet "vsftpd" || yum -y install vsftpd
systemctl enable vsftpd.service
systemctl start vsftpd.service

2. client side

2.1. dahua

./pic/dahua_ftp.png

2.2. foscam

./pic/foscam_ftp.png

3. upload policy

When applying previous client settings, we will notice that the upload path differs depending on the manufacturer.

When a Dahua camera uploads a picture, it will create a default filename such as:

/data1/rcam/ftp/cam061/dahua/cam061/2018-07-13/001/jpg/16/48/22[F][0@0][0].jpg
/data1/rcam/ftp/cam061/dahua/cam061/2019-11-17/pic_001/14.16.33[F][0@0][0].jpg

When a Foscam camera uploads a picture, it will create a default filename such as:

/data1/rcam/ftp/cam061/foscam/FI9900P_00626E832360/snap/MDAlarm_20180713-161729.jpg

Via a cron job, every minute, a script called /opt/rcam/bin/rcam-ftp-cron will

call another script to rename properly the names.

#!/bin/sh
source /opt/rcam/etc/rcam.conf
for camname in ${allcamnames}
  do /sbin/runuser -l ${camuserid} -c "/opt/rcam/bin/rcam-ftp-rename ~${camuserid}/${camname}/"
  done
exit 0

At the end we will have a nice directory structure as shown:

/data1/rcam/
├── cap
├── ftp
│   ├── cam061
│   │   ├── 20180713
├── log
└── rec
    ├── 20180713
    │   ├── cam061
    │   │   ├── 00
    │   │   ├── 01
    │   │   ├── 02
    │   │   ├── 03
    │   │   ├── 04
    │   │   ├── 05
    │   │   ├── 06
    │   │   ├── 07
    │   │   ├── 08
    │   │   ├── 09
    │   │   ├── 10
    │   │   ├── 11
    │   │   ├── 12
    │   │   ├── 13
    │   │   ├── 14
    │   │   ├── 15
    │   │   ├── 16
    │   │   ├── 17
    │   │   ├── 18
    │   │   ├── 19
    │   │   ├── 20
    │   │   ├── 21
    │   │   ├── 22
    │   │   └── 23