Advertisements

Xiaomi Dafang Hacks: Timelapse Images

With the Wyze and Xiamoi Dafang cameras running the Xiaomi-Dafang Hacks firmware and software, I tried the timelapse functions on the yard camera.

The config/timelapse.conf file:

# Interval between snaps, in seconds
TIMELAPSE_INTERVAL=10
# Duration of the script should run, in minutes, set to 0 for unlimited
TIMELAPSE_DURATION=60
# Save dir config
SAVE_DIR_PER_DAY=1
# Enable compression
COMPRESSION_QUALITY=100

The images, named along the lines of 13-04-2019_191810_001.jpg, appear in the DCIM/timelapse directory, tucked into daily directories with names like 2019-04-13, a mismatch obviously in need of tweaking. There’s also a time_lapse directory which seems like cruft from an earlier revision; you can configure the target directory in scripts/timelapse.sh.

Start the script manually or from a crontab entry, wait until it’s done, then transfer the images to somewhere more convenient with a Bash one-liner:

find /system/sdcard/DCIM/timelapse/ -name \*jpg -exec curl -s -n -T {} ftp://192.168.1.10/Timelapse/ \; 

The -s silences all curl output; omit it until you’re sure the lashup works as you expect. I always forget the backslash before the semicolon terminating the -exec command.

The -n pulls the userID and password from the ~/.netrc file you previously set up for manual ftp sessions:

machine 192.168.1.10
login ftp-user-id
password secret-password

The IP address corresponds to my ancient NAS drive; your mileage may vary.

From my desktop box, mount the NAS drive:

sudo mount -t cifs -o "credentials=/root/.nas-id,vers=1.0,uid=ed" "//nasty/Timelapse" /mnt/part

The drive’s credentials aren’t particularly secret, but tucking them into /root/.nas-id means you could automount the drive with no hassle. The NAS drive requires the oldest possible CIFS version, of course.

Then view the pix:

Xiaomi Dafang - 15-04-2019_13.26.18
Xiaomi Dafang – 15-04-2019_13.26.18

You could set up the camera as an NFS share, but having all the cameras deposit their pix in a common location seems more convenient, particularly after I get around to automating the image transfer. Regrettably, the NAS drive doesn’t support subdirectories.

Advertisements