shadow-1 / yi-hack-v3

Alternative Firmware for Xiaomi Cameras based on Hi3518e Chipset
GNU General Public License v3.0
1.15k stars 152 forks source link

Support of RTSP anytime soon..? #92

Open gojiii opened 6 years ago

gojiii commented 6 years ago

Hello, thanks for making this :) Just wanted to know if a version with RTSP support is incoming anytime soon? Let us know, thanks :)

seydx commented 6 years ago

RTSP pleaaaaaaaase

shadow-1 commented 6 years ago

@gojiii I have been very time poor in the last few months. I already know how I would like to develop RTSP support, however I need to hack some of the Xiaomi programs to determine how they work before I will be able to release something that is stable.

kruschman commented 6 years ago

Would RTSP support without the Yi app compatibility be any easier? I know that there are a lot of people that would basically like a solution like fritz's that works with the new hardware.

galadril commented 6 years ago

https://github.com/shadow-1/yi-hack-v3/issues/15

galadril commented 6 years ago

You can add a bounty on this feature: https://www.bountysource.com/issues/44753535-rtsp-server

shadow-1 commented 6 years ago

@kruschman RTSP support without Yi App compatibility might be a little easier to achieve. However it does have its own challenges which are different.

feeling001 commented 6 years ago

Does somebody have an idea how to capture still images "ie : each X seconds via cron job" to put them on the FTP ? I did'nt find a way to access the device (i suppose trough hi3518e_jpege) to grab images.

(seems to be the same kind of hardware : http://www.itread01.com/articles/1476576329.html)

regards, L.

uorriz commented 6 years ago

I was able to achieve this on my 27US using one of the examples of the SDK. The code is in mpp/samples/venc/sample_venc.c I was able to capture a snapshot and save it as /tmp/sd/snap.jpg (therefore the file snap.jpg is in the root of the SD card) every X ms. Then I created a symlink to snap.jpg from the www directory. My goal was to implement a sort of crude MJPEG server using the already available HTTP server. Unfortunately, this is not going to work because the HTTP requests could be served while the capture program is saving the jpg file. So the next step is to implement an HTTP server directly in the sample program. As soon as I'll have some time I'll work on it.

Obviously this will conflict with the cloud software, so it can only work if the original yi apps are killed.

I'm attaching the binary in case you have a 27US and want to give it a try. To test it, just copy it to the sd card (you can use FTP for that), kill all the yi apps and start it with ./sample_venc 4 sample_venc.tar.gz

shadow-1 commented 6 years ago

@uorriz Great progress! I'm sure this will help many people.

dvv commented 6 years ago

If we have still images we could use them as the source for https://github.com/jacksonliam/mjpg-streamer/tree/master/mjpg-streamer-experimental/plugins/input_file.

dvv commented 6 years ago

@uorriz how do we "kill all the yi apps"?

uorriz commented 6 years ago

@dvv I manually kill them using telnet. Here is a script I launch at startup to disable Internet access and kill all the yi apps:

#!/bin/sh

# disable internet access
route del default

# kill yi processes
killall watch_process
killall cloud
killall mp4record
killall rmm
killall oss
killall dispatch
killall log_server
killall udevd
killall p2p_tnp
killall arp_test
dvv commented 6 years ago

I get

/tmp/sd # ./sample_venc 4
=============SAMPLE_COMM_VI_SetMipiAttr enWDRMode: 0
[Func]:HI_MPI_ISP_MemInit [Line]:144 [Info]:ISP[0] get Mem info failed!
SAMPLE_COMM_ISP_Init: HI_MPI_ISP_Init failed!
[SAMPLE_COMM_VI_StartIspAndVi]-2040: SAMPLE_COMM_VI_StartIspAndVi: Sensor init failed!
[SAMPLE_VENC_1080P_JPEG_Thumb]-1623: start vi failed!
program exit abnormally!
uorriz commented 6 years ago

Two things come to mind: 1) wrong model / sensor. I compiled it to work with the 27US (the 720p model). It will not work with other sensors; 2) yi apps still running;

dvv commented 6 years ago

The model should match. Any trick to check the model/sensor from telnet session?

dvv commented 6 years ago

@uorriz I have

/tmp/sd # rtsp/sample_venc
Usage : ./sample_venc <index>
index:
         0) 1*1080p H264 + 1*VGA H264.
         1) 1*1080p MJPEG encode + 1*1080p jpeg.
         2) low delay encode(only vi-vpss online).
         3) roi background framerate.
         4) Thumbnail of 1*1080p jpeg.
         5) svc-t H264

but the cam is 720p one. Couldn't you post here a 720p version of sample_venc.

TIA, --V

ordimans commented 6 years ago

I am working on RTSP on 47US, i use rtsp2301 .

I have this logwhen i connect to VLC.... `_<><><><>Creat RTP<><><><> pstr=-59927 adding a schedule object action rtsputils.c,322 TRANSFER TO READY STATE! exit Rtsp_state_machine 4 S192.168.0.1 Port:58277 +++++++++++++++++++++ start to play 0 now! +++++++++++++++++++++ Start Playing! exit Rtsp_state_machine 4 SIncoming RTSP connection accepted on socket: 6 EventLoop Connection reached: 4 192.168.0.1 Port:58277 exit Rtsp_state_machine 4 S192.168.0.1 Port:58296 exit Rtsp_state_machine 4 Sfd:4,RTSP connection closed by client. first error,pRtsp is null 192.168.0.1 Port:58296 server:192.168.0.101 port:-1093458630

GetSdpDescr,703===>psp.base64profileid=,psp.base64sps=,psp.base64pps=

exit Rtsp_state_machine 4 S192.168.0.1 Port:58296 transport: RTP/AVP/TCP;unicast;interleaved=0-1 pstr=/TCP;unicast;interleaved=0-1 AAAAAAAAAAA Unsupported Transport,rtspservice.c,1118 TRANSFER TO READY STATE! exit Rtsp_state_machine 4 S192.168.0.1 Port:58296 transport: RTP/AVP;unicast;client_port=59928-59929 !!!!!!!!!!!!!!!!!!!!!!rtp create:addr:100a8c0,port:59928,localc0a80065 <><><><>success creat RTP<><><><> <><><><>Creat RTP<><><><> pstr=-59929 adding a schedule object action rtsputils.c,322 exit Rtsp_state_machine 4 S192.168.0.1 Port:58296 +++++++++++++++++++++ start to play 0 now! +++++++++++++++++++++ Start Playing! exit Rtsp_statemachine 4 S^Cbegin free mem The Server quit! /tmp/sd/test/app # ^C `

kapollo commented 6 years ago

Hi I don't know what exactly rtsp2301 is under the hood, but I do own a D-Link 5222L B2 which is based on Hi3518C, and it has RTSP streaming based on the Live555 media server. Dlink like some other OEMs has gpl code for their gpl sw, and for cameras at least it equals to a buildable fw somewhat (it doesn't contain rootfs, but then neither does their fw updates). All in all there is code for Live555 which already has some interfacing done with the SDK binaries from the chipmaker. It could be a great starting point. At least it should be fairly easy to combine venc with stills and mjpeg stream for starters.

There is also other apporach possible like in Edimax's cameras it uses spook as RTSP server (GPL code also provides source code for spook which interfaces with the raw stream directly). hope this helps, just had some encounters with both and wanted to add my two cents.

dvv commented 6 years ago

@pmarrapese can we look at protocol current documentation?

JocPelletier commented 6 years ago

What happened to @pmarrapese messages about his progress?

dwild commented 6 years ago

He is afraid of infringing the ToS of Xiaomi.

Necromix commented 6 years ago

Initial version (and not stable) of RTSP server and H264 recorder for YHS-113-IR (27US): https://github.com/Necromix/yi-vencrtsp

DarthMadeHer commented 5 years ago

I have copied the yi-vencrtsp files from the SD directory onto a working SD that has shadow-1's firmware hack. My understanding is that the startup.sh will be run and call what it needs to from the yi-hack-v3 dir on the SD card. Do I need to telnet to the camera and manually start the processes? Is the url the same as previous ones rtsp://root:@IP_Address:554/ch0_0.h264?

Edit: Never mind. Turns out the startup.sh wasn't running for some reason, so the init.sh in /home/app was never replaced with the Necromix version. Ran the cp manually.

kaizday commented 5 years ago

@DarthMadeHer so what happens after you cp manually, is rtsp working now? What is the url? Thankx

jpenyc commented 5 years ago

I used this https://github.com/Necromix/yi-vencrtsp on this YHS-113-IR (27US) and it works using vencrtsp How do I get vencrtsp to start on boot without having to ssh in.

Minims commented 5 years ago

@jpenyc Can you explain how you make it working ? I try to follow the readme on my 27US cam, but i may do something wrong. Thank you !

bobaxx commented 5 years ago

Hello. For those who are in the same situation as me: waiting for RTSP on the 27US camera for a looooooooong time. You can do it mixing the two following firmwares: yi-hack-v3 from Shadow1 yi-vencrstp

Here are the steps (it worked for me on 2 different cameras). It's a bit tedious but it works:

1-Copy the files from the "SD" directory from necromix firmware (https://github.com/Necromix/yi-vencrtsp) to the root of your SD card;

2-Flash your camera using yi-hack-v3 and following the steps on the page : https://github.com/shadow-1/yi-hack-v3;

3-After the camera is flashed successfully, you should acess it with its IP in your web browser. For example , mine is 192.168.1.65.

4-Go to "system config" tab and enable telnet server, then apply. Your camera will reboot.

5-Connect to your camera with telnet using its IP, with putty for example. Port is 23, user login is "root", and password is empty. For now, you should be logged on your camera.

6-Use the following commands: cd /tmp/sd/yi-hack-v3/ ./startup.sh

This script will replace some native properties of the original camera firmware. If the script doesn't work (it can happen), you have to do it manually using this command line:

cp /tmp/sd/yi-hack-v3/yi_init.sh /home/app/init.sh

7-After camera reboot, you should be able now to use RTSP ! Unfortunately, you have to start the service manually but hey, it's a good start !

To launch RTSP service, connect to your camera with telnet (as seen before) and type this lines:

cp /tmp/sd/ ./vencrtsp

And voilà ! You can now access RTSP with VLC or another client using rtsp://root@CAMERAIP:554/ch0_1.h264. Mine is rtsp://root@192.168.1.65:554/ch0_1.h264

I noticed a bug when the ambient light is too low. The rtsp service show error "segmentation fault" and stops working.

Enjoy !

McVillano commented 5 years ago

@bobaxx would the original app still work after this mod?¿

Minims commented 5 years ago

RTSP seems working, but i have sometimes some segfaults on my 27US. The original app doesn't work anymore on my side. but you can revert by reinstalling the original yi-hack-v3

McVillano commented 5 years ago

Yep, finally i´ve turned back my camera, i was lookingfor full functional RTSP and the project has been without update for months i need rtsp for Home Assistant

fluidof commented 5 years ago

@bobaxx but just for my understanding, after starting the service with ./vencrtsp shall I have to leave open the SSH connection? Can I close terminal? It seems not...

schermata 2018-09-15 alle 01 06 19
fluidof commented 5 years ago

@bobaxx And, is there a way to run a command at startup to run automatically the ssh root@xxx.xx.xxx. ./tmp/sd/vencrtsp or something similar?

hoopsta1423 commented 5 years ago

@bobaxx This guide worked perfectly for me so thank you! Has anybody had any luck using this with BlueIris? I can connect with VLC but can't get BlueIris to pull the stream in using the rtsp address

jpawlowski commented 5 years ago

That wouldn't work anymore it seems because the kernel modules are not compatible with newer firmware versions. I opened a bug report for it: https://github.com/Necromix/yi-vencrtsp/issues/7

Necromix commented 5 years ago

@fluidof: to start vencrtsp at startup.

Edit the /tmp/sd/yi-hack-v3/yi_init.sh or /home/app/init.sh

Add to line 58 (just before the exit) /tmp/sd/vencrtsp &

Necromix commented 5 years ago

@jpawlowski I anticipated this issue and in my initial plan, I would like to use the original ko from CAM but I never achieve to run yi-vencrtsp on those modules.

We can try https://github.com/Necromix/yi-vencrtsp_v2 which uses all files from cam and extract video from /tmp/view.

lupo-ch commented 5 years ago

I have US47 Yi Home camera with yi-hack-v3 and yi-vencrtsp_v2 running, but I can't connect the camera to RTSP client ... what is the correct URL to connect to? I tested with rtsp://ipaddress:554/ch0_0.h264

mvklingeren commented 5 years ago

That is the correct url.

bobaxx commented 5 years ago

It's a bite late, but the correct adress is rtsp://root@ipaddress:554/ch0_0.h264

plutosherry commented 3 years ago

/home/yi-hack-v3 # ./vencrtsp RTSP:-----Init Rtsp server =============SAMPLE_COMM_VI_SetMipiAttr enWDRMode: 0 [Func]:HI_MPI_ISP_MemInit [Line]:144 [Info]:ISP[0] get Mem info failed! SAMPLE_COMM_ISP_Init: HI_MPI_ISP_Init failed! [SAMPLE_COMM_VI_StartIspAndVi]-2040: SAMPLE_COMM_VI_StartIspAndVi: Sensor init failed! [SAMPLE_VENC_1080P_CLASSIC]-1351: start vi failed! program exit abnormally!