mcchas / g2h-camera-mods

Modifying the G2H camera with rtsp, security and not to call home
MIT License
107 stars 14 forks source link

Enabling RTSP is not working #21

Closed Aleksey-Ivanov closed 2 years ago

Aleksey-Ivanov commented 2 years ago

Hi @mcchas ! Could you help me? I have downloaded your file 'hostname' on sdcard in G2H. After that I opened terminal and executed the command 'netstat -anl'. But I can't see any process is listening on port 554. What am I doing wrong?

image

mcchas commented 2 years ago

@Aleksey-Ivanov which version of the firmware are you using?

Aleksey-Ivanov commented 2 years ago

2.2.1_0001.0515 This is version firmware from the app aqara home

Aleksey-Ivanov commented 2 years ago

@mcchas What do you think about this issue?

mcchas commented 2 years ago

Have you tried the most recent script?

To enable RTSP, the hexdump/sed command just replaces the string 'miio_task' with 'rtsp_task' in a specific location in the camera file. Unfortunately when xiaomi makes updates to their firmware these bytes all shift either up or down slightly and that can break the hexdump/sed command - as it can't find the right 'miio_task' to replace. If you have tried the most recent hostname script and it doesn't work I can help work through updating the script

Aleksey-Ivanov commented 2 years ago

Yes, I've tried using the hostname of the latest version. It will be great if you have a chance to help me. As I understand correctly, after this enabling RTSP, I shouldn't update via aqara home, right?

Aleksey-Ivanov commented 2 years ago

Could you help me, with this issue?

mcchas commented 2 years ago

If you can share your camera binary file I can update the sed command

Aleksey-Ivanov commented 2 years ago

Sure, can you explain how I to get this binary file?

mcchas commented 2 years ago

You could use static compiled binaries for arm7 (https://github.com/therealsaumil/static-arm-bins) but a sure fire way would be to use an SD card to copy the file /local/app.tar.zx to /sdcard.

Insert the card and telnet to the camera. Run the command: cp /local/app.tar.xz /sdcard/ Eject the card and upload the file here.

Aleksey-Ivanov commented 2 years ago

I've downloaded this file. https://drive.google.com/file/d/1zhSRIXfWrbGkpdTHLg56LB5Tb5U_n0Fu/view

mcchas commented 2 years ago

Thanks @Aleksey-Ivanov. Looks like this version is already supported.

$ hexdump -vC camera |grep '0031eb40' | sed 's/00 00 00  6d 69 69 6f 5f 74 61 73/00 00 00  72 74 73 70 5f 74 61 73/'
0031eb40  5f 74 61 73 6b 00 00 00  72 74 73 70 5f 74 61 73  |_task...miio_tas|

Check if the service is listening on port 554?

# netstat -lna |grep 554
tcp        0      0 0.0.0.0:554             0.0.0.0:*               LISTEN 

Can you check if your /etc/tar_app.sh has been updated to patch the camera binary?


# cat /etc/tar_app.sh |grep rtsp
# replace annoying logging call with nop and ignore miio service and start rtsp server```
Aleksey-Ivanov commented 2 years ago

Thanks @Aleksey-Ivanov. Looks like this version is already supported.

$ hexdump -vC camera |grep '0031eb40' | sed 's/00 00 00  6d 69 69 6f 5f 74 61 73/00 00 00  72 74 73 70 5f 74 61 73/'
0031eb40  5f 74 61 73 6b 00 00 00  72 74 73 70 5f 74 61 73  |_task...miio_tas|

Check if the service is listening on port 554?

# netstat -lna |grep 554
tcp        0      0 0.0.0.0:554             0.0.0.0:*               LISTEN 

Can you check if your /etc/tar_app.sh has been updated to patch the camera binary?

# cat /etc/tar_app.sh |grep rtsp
# replace annoying logging call with nop and ignore miio service and start rtsp server```

I guess the port 554 is not listen. image

Can you check if your /etc/tar_app.sh has been updated to patch the camera binary? What do you mean? image

mcchas commented 2 years ago

@Aleksey-Ivanov It looks the file was not updated to patch the camera binary. Make sure the file /etc/tar_app.sh_save has been deleted and then run the hostname script again

Aleksey-Ivanov commented 2 years ago

I've deleted this file and run hostname again. The result is image

image

mcchas commented 2 years ago

Not sure what has happened here, only the tar_app.sh_save should be deleted. Either way you can copy the contents for tar_app.sh from the relevant section (between the EOF tags) of the hostname script. Copy that out into /etc/tar_app.sh and reboot. But that shouldn't be necessary as running the hostname script should create this file... do you get any errors when you run this script?

agrigoriev commented 2 years ago

Hi, Guys! Did it work?

Aleksey-Ivanov commented 2 years ago

@mcchas I've been updated /etc/tar_app.sh and reboot. But i can't find 554 port. image

image

Where I can find log file?

Aleksey-Ivanov commented 2 years ago

@mcchas How I can do full factory reset for G2H? I pressed and hold the button near 10 seconds. But it is not work.

mcchas commented 2 years ago

@Aleksey-Ivanov it should reset if you follow the manufacturers instructions- from memory it will sound a spoken acknowledgment of 'device reset' or similar, possibly in Chinese.

Other than that another user in these issues was able to reset theirs by restoring some files to undo the changes the script makes. It's a unique issue you have, and the script is not 100% plug and play, but it sounds like you need some Linux assistance to debug the running of this script, unless your camera has some strange firmware version- but that seems unlikely. The script simply patches the binary that runs the camera software, if that happened successfully RTSP should start.

Aleksey-Ivanov commented 2 years ago

@mcchas Thanks for your time and your helps! @agrigoriev I've gone it!) I had to reset and re-executed the system with your hostname file.

@mcchas Maybe you know how I can get the stream video from G2H via rtsp in the VLC player?

mcchas commented 2 years ago

@Aleksey-Ivanov that's great! You can use rtsp://<ipaddress/14 in VLC, other paths with other numbers are also available for different resolutions (check the readme).

mouth4war commented 2 years ago

@Aleksey-Ivanov I have the same firmware version camera. How did you get wifi working once you reset? Did you use aqara app or homekit or miio app? I tried resetting again and still doesn't work with a FAT32 formatted 64GB card. My camera doesn't connect to homekit or to aqara app. RTSP also not working.