guino / Merkury1080P

Merkury1080P (CW017) Rooting and Customization
77 stars 16 forks source link

Add Web Interface and easy motion notifications #13

Closed williamkennyAK closed 2 years ago

williamkennyAK commented 2 years ago

I have created push webhooks and integrated in mqtt notifications.

Also, developed a quick and dirty web interface which can do the following:

I plan on continuing work on the web interface, but it is in a stable state ATM.

guino commented 2 years ago

This looks really good, was there a reason why config.cgi is both under cgi-bin and www/cgi-bin ? They looked the same at a quick glance but I did not compare in detail.

I want to load it up on my device and give it a good look but looks like you allow for configuring commands to notify of motion and such which is pretty cool.

It would be very cool if we could add a setting for notify of doorbell push too (for the doorbell devices) which would be just a different notification url (maybe slight different json data). Another suggestion is possibly a camera preview (using snap/mjpeg.cgi) which is obviously not necessary but would make it look more like other existing camera firmware -- even just a link to snap/mjpeg.cgi could be enough (no need to do a full preview on the same page).

You clearly know your way around linux/cgi stuff which is nice to see - kudos.

williamkennyAK commented 2 years ago

They are the same. I have been running a second web server on port 80 whose root is /mnt/mmc01/www/. The index.html file I'm using is purely a redirect to www/cgi-bin/config.cgi. I didn't want to modify index.html in /mnt/mmc01/ This is actually the absolute first time I've messed with any cgi stuff, but I've been messing around with Linux for 20+ years. sh is sh.

williamkennyAK commented 2 years ago

I'm taking a look at your jpeg-arm program and trying to setup a proper build environment to compile for arm. It seems if I try to pipe it to a file the snaphdr that is printed stops it from being recognized as a jpeg file. I'm gonna give it a try to compile this and see what it works, but basically adding an option of svjpg which would suppress the header. Mayber there's a more efficient route? (I'm not a seasoned C programmer)

guino commented 2 years ago

@williamkennyAK you just need an arm toolchain to compile the jpeg code - I used this one https://toolchains.bootlin.com/downloads/releases/toolchains/armv5-eabi/tarballs/armv5-eabi--uclibc--stable-2020.08-1.tar.bz2

If you want the code to output a valid jpeg file you need to remove all lines that write headers and only write the jpeg buffer . The current code is meant to be the output for httpd, that’s why I suggested just showing a link on the config page. Not sure if that’s why you need a jpeg file but the less you write ‘files’ the faster things generally are.

williamkennyAK commented 2 years ago

Agreed, but what I intend to do is save a snap to send as a notification via telegram. I'm starting an ftp server on there which is mounted to my nas which is accessible from home assistant. This way, I can do a telegram notification with a snapshot, and offload videos and images to the nas daily. Giving the option to strip the header just gives more options for use imo.

williamkennyAK commented 2 years ago

Probably t he one thing I want to figure out the most is how to mount an nfs share on the camera that way I can just save snaps and video directly to my nas.

guino commented 2 years ago

The kernel/drivers in these devices are not capable of nfs mounts.

The best option I see is having whatever receives the motion alert pull the jpeg image using snap.cgi and send the telegram message. It is file-less and most of the intensive work happens outside of the device.

williamkennyAK commented 2 years ago

It also makes me wonder what the possibility of putting a custom image on these devices. Would it be possible to build a replacement firmware that is more open? Something that allows us to run a more efficient rtsp/onvif server? I'm gonna have to do some digging to see what's out there.

Have you looked into the OTA update process of these devices? I wouldn't mind sacrificing one of these cameras to more of a teardown if there is a possibility of it working.

williamkennyAK commented 2 years ago

I'm starting to think of an alternative approach to this. I think I'm going to rewrite this interface in python or even similar cgi scripting in a docker container running on a separate computer. This way we can have one central point where telnet commands can be sent to the camera(s) instead of putting extra overhead of running extra services on device. As you cautioned I'm running into performance issues. I'm going to close this PR and continue to develop this new method. I will make a few more changes to my fork and let it be.