guino / Merkury1080P

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

Cannot get MJPEG or SNAP working but RTSP does #19

Open tateconcepts opened 2 years ago

tateconcepts commented 2 years ago

I noticed there is a cgi-bin directory and a reference to a still image and motion jpeg. I have been able to get the device rooted and were able to telnet in and enable ONVIF but I have not had any success in getting this to work with MJPEG or similar. Is this still and issue and if so, how can I get this to write out an mp4 or something I can use with port forwarding to a private cloud service?

guino commented 2 years ago

For mjpeg/snap.cgi to work you have to set the address in the cgi file according to your ppsapp file - if that is not posted with a patch you can post a zip of the ppsapp and I can try to find the address for you.

The only ways to record video from these devices are: 1-cloud storage from the app (usually a paid feature). You will have no control or direct access to video ‘files’ with this. OR 2-SD card storage (configured in the app) which can be continuously or motion detection based. The files recorded in the SD card are not in any ‘common’ format but you usually can play the video (without audio) using VLC by forcing H264 demuxer for playback. OR 3-Configure a client to connect to the ONVIF/RTSP feed and record the video. This could be a software like ispy, blueiris or any nvr device that supports onvif/rtsp. The video will be recorded in whatever format you configure in the client. You can record from mjpeg as well (if properly setup) but it has low frame rate and no audio.

I am unaware of any way to make these devices record video directly in any other format/method and I am sure this is because it would require a lot more cpu and memory from the device.

The cloud recording uses a protocol and authentication proprietary to tuya so even if you could redirect it (which may not be hard) there’s nothing ready/available to receive these recordings so someone would have to spend quite a bit of time writing code to replicate the tuya servers and it would only be useful to tuya devices (not worth the trouble).

tateconcepts commented 2 years ago

--deleted-- Here's one from the current Geenie devices

"devname":"Smart Home Camera", "model":"Mini 7S", "serialno":"100640020", "softwareversion":"4.0.6", "hardwareversion":"M7S_A2_V10_F37", "firmwareversion":"ppstrong-a3-tuya2_merkury-4.0.6.20210310"

guino commented 2 years ago

@tateconcepts there's already a patch and published mjpeg/snap address for this firmware on https://github.com/guino/ppsapp-rtsp/issues/1 :

"snap.cgi and mjpeg.cgi address: 0x03821a4" -- you DO NOT need to patch ppsapp for mjpeg/snap to work, so if you already have ONVIF working all you have to do is set the address in snap.cgi and mjpeg.cgi and it should work.

tateconcepts commented 2 years ago

Thank you!

RomchikL commented 1 year ago

Hello!

I have the similar cam but the fw is ppstrong-a3-tuya2_laxi-4.0.6.20210326.

Could you clarify the address for snap/mjpeg for this camera: {"devname":"Smart Home Camera","model":"Mini 7S","serialno":"100372114","softwareversion":"4.0.6","hardwareversion":"M7S_A2_V10_F37","firmwareversion":"ppstrong-a3-tuya2_laxi-4.0.6.20210326","identity":"M1F0079H3H01700027","authkey":"XXX","deviceid":"pp0184b6ab1f26a1312f","pid":"aaa","WiFi MAC":"XXX","ETH MAC":"XXX"}

(ppsapp is not patched, only enable onvif) ppsapp.zip

guino commented 1 year ago

@RomchikL try these addresses:

snap/mjpeg.cgi address: 0x37c354 play.cgi address: 0x37cb60

RomchikL commented 1 year ago

@guino yep, thanks a lot. These addresses work fine.

To avoid creating a separate issue, could you answer the following questions here.

  1. Is it necessary to clear the mqtt database when using integration with HA (to prevent the hard drive from overflowing)?
  2. Is there an easy way to use commands on the camera from HA (via mqtt or smth else), e.g. to play a (custom) sound when a condition is triggered:
    automation:
    *trigger*
    action:
    - service: mqtt.publish
    data:
    topic: home/camera/my_trigger
    payload: *command to play a sound*

    I assume this can be done via log_parser.sh patching like

    *record home/camera/my_trigger -> log file*
    if contains "$BUF" "*command to play a sound*"; then
            /mnt/mmc01/cgi-bin/play.cgi /mnt/mmc01/my_sound.wav

    Will it work? Or there is another way to send commands to the camera.

guino commented 1 year ago

@RomchikL

  1. I'm not sure what is the "mqtt database" you mentioned -- my understanding of mqtt is that they're just temporary messages between deivice/host unless HA is keeping a log of them (which is only helpful for debugging). If HA is keeping these messages then you should probably delete/disable them unless you're debugging. On the device itself there are video recordings that may be saved on the SD card and you need to make sure they don't fill up the SD card (or your files/settings will get deleted), so always backup your SD card and I recommend configuring the cleanup.cgi for self-cleaning.

  2. You may want to look at this wiki (basically your log_parser idea): https://github.com/guino/BazzDoorbell/wiki/%5BHow-to%5D-Play-a-sound-when-motion-is-detected -- you CAN also trigger playback using an URL on the device as described here -- the wav files need to be saved on the device (i.e. SD card).

RomchikL commented 1 year ago

@guino, Thank You!

  1. Now I understood how mqtt works (that the messages are temporary). Ya, I configured everything except cleaning. Now I'm trying to configure it. My ppsapp is different from yours, so I need to fix the config.

  2. I saw this instruction, but I thought an additional command is needed (with mosquitto_sub, but how to use it in log_parser?). I can playback using an URL, yep, but this is only an example. My main question was about sending an arbitrary command to the camera, i.e, two-way communication. (without mqtt): maybe I can create the necessary script my_script.cgi like play.cgi and run it using an URL to this script.

Here are keys to the config files of my cam (ppstrong-a3-tuya2_laxi-4.0.6.20210326). Maybe it will be useful to someone.

snap/mjpeg.cgi address: 0x37c354 play.cgi address: 0x37cb60

Since there is no letter 'n' in the log (see the screenshot below), I use such log_parser:

        if contains "$BUF" "motio"; then
             /mnt/mmc01/mosquitto_pub -h 192.168.1.100 -u login -P password -m "detected" -t home/laxicam_mini7s/motion

For cleaning try this line

/mnt/mmc01/busybox find /mnt/mmc01/sdrec/T-100372114/mp4rec -type d -mtime +$DAYS -exec echo rm -rf {} \; -exec rm -rf {} \;

new

RomchikL commented 1 year ago

Cleanup works fine with such line, adjust your SERIAL like

SERIAL=123456789
/mnt/mmc01/busybox find /mnt/mmc01/sdrec/T-$SERIAL/mp4rec ...

For playback the following config works (via URL in Home Assistant):

shell_command:
  play_wav_laxicam_mini7s: 'curl -X POST "http://login:pass@IP:8080/cgi-bin/play.cgi?/home/sound/dingdong.wav"'

automation:
  ...
  action:
     - service: shell_command.play_wav_laxicam_mini7s

Via mqtt_sub I have no idea.