667bdrm / sofiactl

sofiactl is an open source cross-platform tool and sdk to control Sofia powered Hi35xx DVR devices
78 stars 22 forks source link

Set NVR RTSP stream url #11

Open anktx opened 3 years ago

anktx commented 3 years ago

One of my cameras have poor ONVIF support, so NVR cannot get stream from it. I'm trying to set RTSP stream address for a channel directly, using sofiactl.pl As I see, there are several options, probably responding for this: MainRtspUrl, SubRtspUrl, Protocol. But when I set direct RTSP stream in NVR channel 1 (MainRtspUrl), nothing happens, the picture does not appear. Does anyone know if this is possible and can suggest the correct format for the above options?

./sofiactl.pl --user admin --host nvr-32 --port 34567 --command ConfigGet -co NetWork.RemoteDeviceV3[0] | jq { "NetWork.RemoteDeviceV3[0]": { "TourIntv": 10, "SynchResolution": false, "ConnType": "SINGLE", "EnCheckTime": true, "Decoder": [ { "PassWord": "", "ConfName": "chConfig1", "IPAddress": "192.168.1.41", "Enable": true, "MacAddr": "", "SerialNo": "", "UserName": "admin", "StreamType": "MAIN", "SubRtspUrl": "", "Interval": 0, "MainRtspUrl": "", "Channel": 0, "Port": 34567, "DevType": "IPC", "Protocol": "TCP" } ], "SingleConnId": "0x00000001", "Enable": true } }

667bdrm commented 3 years ago

Hi. I'm using the following script to get rtsp snapshot from non-onvif Sofia powered cameras:

#!/bin/sh

url='rtsp://192.168.1.99:554/?user=myuser&password=mypass&channel=1&stream=1.sdp'

avconv -i "$url" -r 1 -vsync 1 -qscale 1 -y -frames 1 -ss 2 -f image2 /var/www/images/dvr/cam00.jpg > /dev/null 2>&1

1.sdp - low res stream, 0.sdp - hi res stream

Check in 554 port open, try to enable it in configuration.

Your url format could be different, try to search web for additional variants.

anktx commented 3 years ago

Thank you for your answer!

The problem is not to get a snapshot from the camera, but to manually write the url of the camera stream into the NVR, which has incorrect ONVIF support.

Receiving stream from camera works fine:

$ mpv rtsp://192.168.1.168:554/PSIA/Streaming/channels/2\?videoCodecType=H.264 (+) Video --vid=1 (h264 1280x1024 75.000fps) (+) Audio --aid=1 (pcm_mulaw 1ch 8000Hz) File tags: Comment: 2?videoCodecType=H.264 Title: RTSP/RTP stream from IPNC Using hardware decoding (vaapi). AO: [pulse] 8000Hz mono 1ch s16 VO: [vaapi] 1280x1024 vaapi[nv12]

But when I try to connect camera via ONVIF to NVR, it says that the camera status is: "Not logged in", despite the fact that the credentials are correct.

2021-01-07-112200 2021-01-07-112638

Seeing that there are RTSP options in the config, I tried to register the stream address manually, but NVR don't use it. So I'm wondering if any other options that need to be changed?

awerskto commented 3 years ago

Hi. I'm using the following script to get rtsp snapshot from non-onvif Sofia powered cameras:

#!/bin/sh

url='rtsp://192.168.1.99:554/?user=myuser&password=mypass&channel=1&stream=1.sdp'

avconv -i "$url" -r 1 -vsync 1 -qscale 1 -y -frames 1 -ss 2 -f image2 /var/www/images/dvr/cam00.jpg > /dev/null 2>&1

1.sdp - low res stream, 0.sdp - hi res stream

Check in 554 port open, try to enable it in configuration.

Your url format could be different, try to search web for additional variants.

Hi

What version of avconv are you using? On what system? I just compiled version 12.3 on ubuntu 20.04 and I have an error:

./avconv -i rtsp://admin:test@192.168.1.33:554/user=admin&password=test&channel=4&stream=0.sdp? -r 1 -vsync 1 -qscale 1 -y -frames 1 -ss 2 -f image2 /home/test/cctv/avconv/bin/cam00.jpg [1] 1750916 [2] 1750917 [3] 1750918 avconv version 12.3, Copyright (c) 2000-2018 the Libav developers built on Mar 16 2021 11:00:10 with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04) rtsp://admin:test@192.168.1.33:554/user=admin: Invalid data found when processing input -r: command not found [1] Exit 1 ./avconv -i rtsp://admin:test@192.168.1.33:554/user=admin [2]- Done password=test [3]+ Done channel=4

Regards

667bdrm commented 3 years ago

Have you tried to put the url into ''?" When I suggested this command I've used it on Raspbian (Debian Jessie based) on Raspberry Pi B+.

Here is how I doing the same on the latest Ubuntu 20.04 LTS:

url='rtsp://192.168.1.1:554/?user='$USER'&password='$PASS'&channel='$i'&stream=1.sdp' ffmpeg -i "$url" -r 1 -vsync 1 -qscale 1 -y -frames 1 -ss 2 -f image2 /tmp/cam0$i.jpg

As I remember avconv at some point has been forked from ffmpeg.