How to setup dynamic live stream using https instead of rtsp?
AnsweredIn our current system, we have two NxWitness servers. The first one is the central NxWitness Server where the cameras are configured, and the second one is the streaming server. The streaming server takes device information from the central server via rest/v1/devices/*/searches, transforms the device information by adding custom dynamic IDs, and serves them for streaming.
All the steps related to dynamic live streaming are performed by the integration API as a middleware service.
We have implemented the following steps in order to proceed with dynamic live streaming for each of the cameras:
1. Obtain camera information from the central NxWitness server using the camera ID and credentials via https://<central-nx-witness-host>/rest/v1/devices?_with=id,name,model,physicalId,status,vendor&_orderBy=name
2. After getting camera information, create the HTTPS URL using the relevant user, password, host, camera ID, resolution, and position as query parameters (i.e., https://<user>:<pass>@<central-nx-witness-host>/media/<camera-id>.webm?resolution=<resolution>&pos=<pos>).
3. Send a POST request to the https://<streaming-nx-witness-host>/rest/v1/devices/*/searches endpoint with the following body data to retrieve camera and its related information like devices, status and etc
{
"ip": "https://<user>:<pass>@<central-nx-witness-host>/media/<camera-id>.webm?resolution=<resolution>&pos=<pos>",
"credentials": { "user": user, "password": password },
"mode": "waitResults"
}
4. After obtaining the information, generate a random ID to assign to the camera information, create a new payload data, and then send a POST request to https://streaming-server-host//rest/v1/devices to create a virtual dynamic live stream camera:
const newId = randomUUID();
let dynamicStreamingCamera = {
"name": `dynamic-stream-${newId}`,
"credentials": deviceInfo.credentials,
"physicalId": newId,
"isManuallyAdded": true,
"mac": deviceInfo.mac,
"model": deviceInfo.model,
"serverId": deviceInfo.serverId,
"typeId": deviceInfo.typeId,
"url": deviceInfo.url,
"vendor": deviceInfo.vendor
};
5. Once the dynamic camere are set up inside Streaming NxWitness server, respond with the dynamic streaming URL of the virtual camera to the client to retrieve the live feed.
Currently, I faced the some issue in Step 3
The ip passed inside the data payload can only work with RTSP and reponse the related device information. However, when I pass ip that starts with HTTPS, there is no device response from the API.
When I send POST request with the following data
{
"ip": "rtsp://<user>:<pass>@<central-nx-witness-host>/<camera-id>?resolution=<resolution>&pos=<pos>",
"credentials": { "user": "user", "password": "pass"},
"mode": "waitResults"
}
It response the following
{
"credentials": {
"password": "user",
"user": "pass"
},
"devices": [
{
"credentials": {
"password": "user",
"user": "pass"
},
"group": {
"id": "",
"name": ""
},
"id": "{a376b83f-b941-2036-c025-5d16deb863d6}",
"isManuallyAdded": true,
"mac": "",
"model": "0035f839-fdaa-fd98-7e29-b6cb4d8029a9.webm",
"name": "GENERIC_RTSP-0035f839-fdaa-fd98-7e29-b6cb4d8029a9.webm",
"physicalId": "4f4f4ac76d990aab82671f5b3625c3af",
"serverId": "{b43a0307-d69d-05b7-cec1-5fc659d95bc1}",
"typeId": "{7b2a1e32-d7ec-7a04-3c64-898ff33ef37c}",
"url": "rtsp://<central-nx-witness-host>/media/0035f839-fdaa-fd98-7e29-b6cb4d8029a9.webm?resolution=720p&pos=0",
"vendor": "GENERIC_RTSP"
}
],
"endIp": "",
"id": "{f5da0d42-2b0f-411a-b00d-480b4addd4e9}",
"ip": "rtsp://<user>:<pass>@<central-nx-witness-host>/media/0035f839-fdaa-fd98-7e29-b6cb4d8029a9.webm?resolution=720p&pos=0",
"mode": "waitResults",
"port": 0,
"startIp": "",
"status": {
"current": "100",
"state": "Finished",
"total": "100"
}
}
But when I request with
{
"ip": "https://<user>:<pass>@<central-nx-witness-host>/media/<camera-id>.webm?resolution=<resolution>&pos=<pos>",
"credentials": { "user": user, "password": password },
"mode": "waitResults"
}
The response is just empty array
So how can I get the devices related to provided ip start with https?
-
Hello,
Here are options possible for adding a device
- ONVIF via auto discover or manually via HTTP
- motion jpeg stream via HTTP
- RTSP stream
- UDP
That means, an RTSP stream added with the
"url": "rtsp://<central-nx-witness-host>/media/0035f839-fdaa-fd98-7e29-b6cb4d8029a9.webm?resolution=720p&pos=0"
"ip": "rtsp://<user>:<pass>@<central-nx-witness-host>/media/0035f839-fdaa-fd98-7e29-b6cb4d8029a9.webm?resolution=720p&pos=0"
won't ever work, because the url provides and HTTP streaming interface, while you're trying to request the steam via RTSP protocol.
Regarding media interfaces of the Server
In your system of two Server, you could address your requests to the "streaming server" (in your terms) for the cameras as if they are connected locally to the "streaming server". The Server knows what Server in the system to pull the video stream from.
In other words, a request looking like
"rtsp://<user>:<pass>@<streaming-server>/<camera-id>?resolution=<resolution>&pos=<pos>
will return a stream from the camera with camera-id actually connected to central-nx-witness-host.
The proxying happens internally and seamlessly.
0 -
Thank you for your answer, Andrey Terentyev. However, based on our infrastructure setup, the central and streaming servers will not be on the same VLAN. The infrastructure team has configured the HTTPS domain for the central NX server, and they are reluctant to expose RTSP due to security concerns.
Consequently, we attempted to send the RTSP request via the HTTPS domain, but encountered an error indicating that the RTSP URL was not found. And I updated the code to request the streaming device information using the HTTPS URL with the appropriate parameters.
Unfortunately, the response from the devices is empty, and as a result, we are unable to establish live streaming from the central server via the streaming server.
0 -
Hi,
The infrastructure team has configured the HTTPS domain for the central NX server, and they are reluctant to expose RTSP due to security concerns.
All the inter-server communication (including internal stream proxying) is performed via the TCP port 7001.
You should ask your infrastructure team to enable not HTTPS with is TCP 443 by default, but communication via TCP port 7001.
0
Post is closed for comments.
Comments
3 comments