keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.68k stars 235 forks source link

Reolink RLC-410-5MP using suggested arguments - no video feeds or recording - Improvement suggestion Use Snapshot url for less overhead #91

Closed GhostlyCrowd closed 2 years ago

GhostlyCrowd commented 2 years ago

I had this working one night (recording and mobile app, web interface would not live view), decided to shut it down for the night and now I cannot get it to work again. Ubuntu Server 21.04 in a Hyper-V instance.

The screen shots seems to cycle from blurry and distorted to clear and perfect.

For what its worth its a UDM-PRO with Protect 1.19.2

Below is the output I see its in a loop.

`2021-09-23 13:52:17 udnt-dns RTSPCam[73248] INFO Processing [ChangeVideoSettings] message

2021-09-23 13:52:17 udnt-dns RTSPCam[73248] INFO Spawning ffmpeg for video2 (vvJ3yWvxZINKJ3Y8): ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:12345678@192.168.7.100:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=vvJ3yWvxZINKJ3Y8 -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550

2021-09-23 13:52:22 udnt-dns RTSPCam[73248] INFO Processing [NetworkStatus] message

2021-09-23 13:52:22 udnt-dns RTSPCam[73248] INFO Processing [GetSystemStats] message

2021-09-23 13:52:30 udnt-dns RTSPCam[73248] INFO Processing [ChangeVideoSettings] message

2021-09-23 13:52:30 udnt-dns RTSPCam[73248] INFO Spawning ffmpeg for video2 (vvJ3yWvxZINKJ3Y8): ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:12345678@192.168.7.100:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=vvJ3yWvxZINKJ3Y8 -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550

2021-09-23 13:52:30 udnt-dns RTSPCam[73248] INFO Processing [ChangeVideoSettings] message

2021-09-23 13:52:30 udnt-dns RTSPCam[73248] INFO Spawning ffmpeg for video1 (dLA1PwkdkNwvKQ1Q): ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:12345678@192.168.7.100:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=dLA1PwkdkNwvKQ1Q -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550

2021-09-23 13:52:30 udnt-dns RTSPCam[73248] INFO Processing [ChangeVideoSettings] message

2021-09-23 13:52:30 udnt-dns RTSPCam[73248] INFO Spawning ffmpeg for video3 (6IGqHHJaoygDHSBy): ffmpeg -nostdin -y -stimeout 15000000 -rtsp_transport tcp -i "rtsp://unifiprotect:12345678@192.168.7.100:554//h264Preview_01_main" -c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k -metadata streamname=6IGqHHJaoygDHSBy -f flv - | /usr/bin/python3 -m unifi.clock_sync | nc 192.168.7.245 7550

GhostlyCrowd commented 2 years ago

I think part of my issues is the overhead for the snapshot is using 150% cpu and its spawning twice and ive given it 12vcpus

reolink supports taking a snapshot jpeg its self seperatly via this format example, can we get this implimented and see ifi t helps us Reolink users.

http://(ip address)/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=(any combination of numbers and letters)&user=(user name)&password=(user password)

For Example

http://192.168.2.119/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=123456

main and sub video streams are located here as en example

rtsp://admin:password@192.168.2.119:554//h264Preview_01_main

rtsp://admin:password@192.168.2.119:554//h264Preview_01_sub

GhostlyCrowd commented 2 years ago

After looking at the reolink_nvr stuff (im no python pro) its almost working. I edited the snapshot part to use the proper url format in the reolink_nvr

async def get_snapshot(self) -> Path: img_file = Path(self.snapshot_dir, "screen.jpg") url = ( f"http://{self.args.ip}" f"/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C" f"&user={self.args.username}&password={self.args.password}" ) await self.fetch_to_file(url, img_file) returnimg_file `

However im getting this error when i try to send the cam specific ffmpeg arguments to it

unifi-cam-proxy -H 192.168.7.245 -i 192.168.7.100 --mac 'ec:71:db:dc:47:b8' -c client.pem -t 505zI2WzHsHCusWGVM8aOQtNTGLfclFy reolink_nvr --rtsp-transport udp --username unifiprotect --password 12345678 --channel 0 --ffmpeg-args '-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001:fixed_frame_rate_flag=1" -ar 32000 -ac 2 -codec:a aac -b:a 32k'

usage: unifi-cam-proxy reolink_nvr [-h] [--ffmpeg-args FFMPEG_ARGS] [--rtsp-transport {tcp,udp,http,udp_multicast}] --username USERNAME --password PASSWORD --channel CHANNEL unifi-cam-proxy reolink_nvr: error: argument --ffmpeg-args/-f: expected one argument

GhostlyCrowd commented 2 years ago

in the unif protect error log this is all i see

2021-09-23T21:34:36.407Z - error: Request timed out.. Request 'GetSystemStats' r ejected. MESSAGE_ID: 16147 { request: { payload: {} }, response: {} } 2021-09-23T21:34:46.405Z - error: Request timed out.. Request 'GetSystemStats' r ejected. MESSAGE_ID: 16150 { request: { payload: {} }, response: {} } 2021-09-23T21:34:56.405Z - error: Request timed out.. Request 'GetSystemStats' r ejected. MESSAGE_ID: 16155 { request: { payload: {} }, response: {} } 2021-09-23T21:35:06.411Z - error: Request timed out.. Request 'GetSystemStats' r ejected. MESSAGE_ID: 16161 { request: { payload: {} }, response: {} } 2021-09-23T21:35:16.412Z - error: Request timed out.. Request 'GetSystemStats' r ejected. MESSAGE_ID: 16164 { request: { payload: {} }, response: {} } 2021-09-23T21:35:26.415Z - error: Request timed out.. Request 'GetSystemStats' rejected. MESSAGE_ID: 16170 { request: { payload: {} }, response: {} } 2021-09-23T21:35:36.421Z - error: Request timed out.. Request 'GetSystemStats' rejected. MESSAGE_ID: 16175 { request: { payload: {} }, response: {} } 2021-09-23T21:35:46.583Z - error: Request timed out.. Request 'GetSystemStats' rejected. MESSAGE_ID: 16178 { request: { payload: {} }, response: {} } 2021-09-23T21:35:56.591Z - error: Request timed out.. Request 'GetSystemStats' rejected. MESSAGE_ID: 16184 { request: { payload: {} }, response: {} }

Which i assume is why i get no video feed Also this in the service log on unifi protect

image

GhostlyCrowd commented 2 years ago

@keshavdv I dont know if this will help but it might help resolve reolink compatibility issues since its a sanctioned full blown python api https://github.com/ReolinkCameraAPI/reolinkapipy

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.