Yi-RTS3903N-RTSPServer icon indicating copy to clipboard operation
Yi-RTS3903N-RTSPServer copied to clipboard

Sricam SP017: stream fails to open /dev/video51

Open ubeF opened this issue 1 year ago • 6 comments

I tried to run the RTSPServer on a Sricam SP017, which is a different RTS3930N based IP camera. The server itself seems to work but stream fails to set up the fifo stream in /tmp/h264_high_fifo.

Stream fails after calling rts_av_create_isp_chn(&isp_attr) and outputs "fail to create isp chn, ret = -21". It turns out that rts_av_create_isp_chn tries to open /dev/video51 without previously creating the device.

Is the creation of /dev/video51 already taken care of by a different program in YI Cameras?

I cant find any public information on the rtscamkit library or the camera drivers, so i don't know what rts_av_create_isp_chn actually does and how the camera device is supposed to be set up. Can anyone point me in the direction of the source or some documentation for the library?

ubeF avatar Nov 29 '24 22:11 ubeF

@ubeF it's been a while since I worked on this project.

If I remember correctly, the drivers load first which then setup the /dev/video51 instances. It could be that your libraries don't match those that were compiled with the binary.

Do you have a firmware dump?

cjj25 avatar Nov 29 '24 22:11 cjj25

I don't have a full dump, but i have the relevant files here firmware.zip

/etc/init.d/rcS is run on startup, does some setup stuff, runs /rom/setup.sh and then /ipc/ipc, which handles all of the camera stuff

/rom/setup.sh does not initially exist and is writable, so i used it to start your scripts.

But it turns out that /dev/video51 is not created before /ipc/ipc is run, so stream doesn't work. I poked around /ipc/ipc a bit and i think it might use rts_av_create_chn() to create the video device but I'm not sure what exactly that function does.

ubeF avatar Nov 29 '24 22:11 ubeF

Yes, you're right. I remember now!

If you would like more information on that functionality see here.

cjj25 avatar Nov 30 '24 11:11 cjj25

Doing some research into this camera, it appears to support ONVIF. This means it could potentially have an RTSP server built into the IPC.

It would be interesting to see we could patch this binary to enable it by default.

cjj25 avatar Nov 30 '24 12:11 cjj25

Yes, you're right. I remember now!

If you would like more information on that functionality see here.

That's precisely the function that throws the error. I analyzed stream with strace and it turns out, that rts_av_create_isp_chn tries to open /dev/video51 expecting it to already exist.

ipc uses rts_av_create_chn which passes the create flag to open, so it actually creates /dev/video51. But i don't think simply replacing that function will work.

ubeF avatar Nov 30 '24 13:11 ubeF

I found the code responsible for intializing /dev/videoX in ipc and added it to stream.c. Now i can capture raw footage from /dev/video51.

Stream creates /tmp/h264_high_fifo, but it seems to be empty. There's probably a problem with the encoding, but i don't quite understand the library functions you are using.

Any ideas on what the issue could be?

ubeF avatar Dec 03 '24 01:12 ubeF

Have you made any progress @ubeF?

roondar avatar Jul 28 '25 17:07 roondar

I never got the hardware-accelerated encoding working. Decided to put the RTSP-Server on another device and stream the video there via ffmpeg. But because it's encoding everything via the CPU it's only 360x240 video at like 5 FPS

ubeF avatar Aug 03 '25 22:08 ubeF