For this article we will assume your Shinobi installation is found in the default directory, /home/Shinobi.

What is FTP?

FTP stands for File Transfer Protocol and it is a way of transferring files between computers.

How does it apply to Triggering an Event?

Many IP cameras come with a built-in Motion Detector and FTP client. When motion is detected the camera can upload a snapshot or short clip to your specified FTP server.

Shinobi can now create an FTP server for this purpose. When Shinobi receives a new file it will see it as a reason to trigger an event, just like how it would trigger if Shinobi's built-in motion detector had caught motion.

When a JPEG file is placed into the directory it will treat it as a snapshot and copy it to the streams directory to be used for notifications and as the most recent view-able image through the /jpeg/ API method.

Placing any other type of file will simply invoke a trigger, just without a snapshot being provisioned.

Why do this?

  • The Shinobi server isn't doing the Motion Detection processing anymore, the camera takes the load instead.
  • The camera is better capable of detecting something sooner because its accessing the stream at the hardware level.
  • The camera may have other hardware to make the Motion Detection even more precise than if you were to simply check for pixel changes in a video stream.
  • The Motion Detection within your camera may be something you are already familiar with. You can skip learning how to use Shinobi's Motion Detection and still make use of all the Triggering options.

Enabling the Drop-In Event server and FTP server

1. Add the following options to your conf.json.

  "dropInEventServer":true,
  "ftpServer":true,

Run these commands to do so.

cd /home/Shinobi
node tools/modifyConfiguration.js addToConfig='{"dropInEventServer":true, "ftpServer":true}'

2. Now restart Shinobi

pm2 restart camera

Available Options

Option Description Example Value
dropInEventServer Enabled a directory watcher to trigger events. When a file is added to the specified folder. Default is null. true
dropInEventsDir Specified directory for file drop-ins that trigger events. Default is a folder labelled dropInEvents inside the streamsDir. /dev/shm/stream/dropInEvents
dropInEventDeleteFileAfterTrigger The file dropped in to create the trigger will be deleted after 5 minutes. Default is true. false
ftpServer Toggle for the FTP server. Default is false. true
ftpServerPort Specify a specific port for the FTP server to run on. Default is 21. 1337
ftpServerUrl With this you can specify a more secure connection method or bind to a specific IP available on the machine. The default binds to all IPv4 Addresses, IPv6 is not available at this time. Default is ftp://0.0.0.0:{{PORT}}. ftps://0.0.0.0:{{PORT}}

Configure Monitor Settings for FTP Triggering

1. Open the Monitor Settings and switch to Advanced view to reveal the Detector Settings.

2. Within the Detector Settings set the following fields.

  • Send Frames : No

3. For Recording when a file is dropped in set the following options.

  • Identity > Mode : Watch-Only
  • Detector Settings > How To Record : Traditional
  • Detector Settings > Reset Timeout on Next Event : Yes

Setting up the FTP Client in a Camera

For this tutorial we will use a Reolink C1 Pro

1. Open the Device Settings by clicking the gear icon in the top right.

2. Click Network then Advanced on the left and finally FTP at the top.

3. Set the following fields to setup the Shinobi Event Trigger.

  • FTP Server : The IP Address of the machine running Shinobi. IPv4 Address is required.
  • FTP Port : The Port in which the FTP Server is running, default is 21.
  • Username : The Username you use to login to the Shinobi dashboard. This can also be an API key. Structure must simulate an Email address, [API KEY]@Shinobi
  • Password : The Password you use to login to the Shinobi dashboard. If an API key is used for the Username the Password must be the Group Key.
  • Upload Directory : Set it as the Monitor ID that will be triggered. Syntax would be /[MONITOR_ID].
  • Upload Picture Only : Enable this to upload only a single file for the trigger. This also guarantees the fastest trigger possible from the camera. This option may not exist in other brands.

4. Press Test and it will trigger an event in Shinobi.

5. Save the changes.

Enjoy!