In my previous post I configured basic video capabilities for web camera connected to OpenWRT router. Today I decided to go further and install more advanced software that would in fact be a surveillance solution. I decided to try with Motion package and MotionEye interface for it.
Installing it first required a bit of work to make more space available on my router, I’ve explained it step by step in this post.
After getting more space I’ve installed on that new partition required packages:
opkg update opkg install python -d ubi1 opkg install curl -d ubi1 opkg install motion -d ubi1 opkg install ffmpeg -d ubi1 opkg install v4l-utils -d ubi1 opkg install python-pip -d ubi1 opkg install python-dev -d ubi1 opkg install python-curl -d ubi1 opkg install python-pillow -d ubi1
Now I needed to use PIP to install MotionEye itself:
python -m pip install --upgrade setuptools python -m pip install motioneye
That way they were installed on main, smaller ubi0 partition, but it was just few MBs, most of heavier files were installed by opkg to bigger ubi1 partition so I was ok with that. I created also config file location and copied sample config there:
mkdir -p /etc/motioneye mkdir -p /mnt/sda1/motioneye/log mkdir -p /mnt/sda1/motioneye/media mkdir -p /mnt/sda1/motioneye/run cp /usr/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motion.conf
Then I edited config file to move needed locations to external HDD:
# path to the configuration directory (must be writable by motionEye) conf_path /etc/motioneye # path to the directory where pid files go (must be writable by motionEye) run_path /mnt/sda1/motioneye/run # path to the directory where log files go (must be writable by motionEye) log_path /mnt/sda1/motioneye/log # default output path for media files (must be writable by motionEye) media_path /mnt/sda1/motioneye/media
After that everything was ready to play, so I ran:
root@WnekoWrt:~# meyectl startserver -c /etc/motioneye/motion.conf
And was able to access MotionEye by 192.168.1.1:8765 🙂
Now I need to get to know it and configure it, but for Today I’m happy with current progress!
UPDATE after some testing
Unfortunately, after whole evening of testing in the end this doesn’t seem to be viable option on my router. When playing around with configuration of MotionEye when setting anything over 1000px on long edge camera was just stopping to work. So I started to test with motion itself – and I was able to run it successfully at 800x448px 5fps, anything more and device can run out of memory, or camera stops working. So it just doesn’t feel like enough for XXI century surveillance.
Also it seems motion package available in opkg has ffmpeg support disabled – so no recording of video without compiling my own package. At least saving images, with resolution settings as above, works like a charm – when it detects motion it saves series of images – but again they are quite low resolution.
As you can see – it works. But is it useful? Xiaomi camera for 150pln definitely seems much more useful than that. This probably could be good option but with much better device – when I’ll finally install my server with full Linux on Xeon powered virtual machine with much more ram available I will definitely come back to this, but for now resources – CPU and RAM – needed to keep it working don’t seem for me to be worth it.
To be honest, seeing how much better mjpeg-streamer was performing I was expecting much better results. But I guess motion needs to keep multiple images to be able to detect motion and also perform much more calculations for actual motion detection and here it’s where R6220 is just not powerful enough. But still – mjpeg-streamer is perfectly viable for real-time streaming, so I’ll just stick with it as a way of checking Xiaomi’s blind spot if needed.