After running into a bug with VLC capturing images from an RTSP stream in Linux, I decided to go a different route for capturing time lapses from my 3D printer and that was to use a local script on the PI that can be run with command line parameters to set the interval and duration of the capture and have the images output to a network share, this should satisfy the same goal as the RTSP stream by not having the PI store or write data to the SD card and so prolong its life
I went about the process in this order:
- Setup a share on my workstation
- On the pi “sudo apt-get install samba-common smbclient samba-common-bin smbclient cifs-utils”
- Add the share to /etc/fstab by appending “//<server>/Timelapse /mnt/timelapse cifs guest,rw,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0”
- Reboot the Pi to ensure the mount is permanent
After that I wrote a simple script to allow for timelapse capture:
#!/bin/bash#Timelapse from an RPi Cameraif [ $# == 0 ]thenechoecho “usage: $0 [runtime] [interval] [destination]”echoecho ‘All times are in seconds (3600 seconds per hour)’echoecho “example: $0 3600 60 ~/images/timelapse”exitfiruntime=$1interval=$2if [ $# -gt 2 ]thenstore_path=$3elsestore_path=/mnt/timelapsefiwhile [ $SECONDS -lt $runtime ]dodatetime=$(date +”%FT%H%M%S”)raspistill -vf -hf -o $store_path/$datetime.jpgsleep $intervaldoneecho ‘time lapse complete’
Unfortunately I ran into trouble where whenever calling raspistill I would get an ENOSPC error and it would fail to do any capturing, I ran a firmware update and that led me down a rabbit hole where it looks like the rpi-update is broken on older Pis such as my Rpi 1B, this required downloading the files manually and forcing the update without a download as per the below:
curl -L https://github.com/Hexxeh/rpi-firmware/archive/master.tar.gz -o master.tar.gz
sudo tar -xvzf /home/pi/master.tar.gz –strip-components=1
sudo SKIP_DOWNLOAD=1 rpi-update
Finally, with all of that complete I tried again and it failed, reason being I still had my streaming script running from the previous article! I went through and disabled the service I had setup previously:
systemctl disable stream-rstp.sh
And tested and successfully got an image off the camera, I tested my script, and it worked!
I can now grab high resolution time lapses of my 3D printer by SSHing into my Pi and running a single command string!