Open skarotech opened 1 month ago
When I want the URL for a specific profile make the same call cam.getStreamURI(opts, (err,steam) => { // check err // use stream.uri }
The issue is likely to be in how you populate the options. As well as profileToken you need to set 'protocol' and 'stream' in the Options. For a RTSP stream where the video comes via TCP via the RTSP connection then set protocol to "RTSP" (like you do) and include the 'stream' set to "RTP-Unicast" For UDP video, you need protocol set to "UDP" and the stream set to "RTP-Unicast"
You can also ask for Multicast and for RTSP over HTTP but will assume you just want these two common ones.
The ONVIF user guide (onvif.org) has a table for what to use for 'protocol' and 'stream'
I have an IVSEC NVR, with multiple cameras, the connect process is showing me the multiple profile tokens (via the profiles object)
profile_0_main profile_0_sub profile_1_main profile_1_sub etc...
and when calling the getStreamUri code (my code) // Retrieve the RTSP stream URI cam.getStreamUri({ protocol: 'RTSP'}, (err, stream) => { if (err) { console.log('{"rtsp":""}'); return; } const rtspUrl = new URL(stream.uri); const rtspPath = rtspUrl.pathname + rtspUrl.search; console.log('{"rtsp":"' + rtspPath + '"}');
});
it returns the default camera streams {"rtsp":"/rtsp/streaming?channel=1&subtype=0"} {"rtsp_port":"80"} {"mjpeg":"/rtsp/streaming?channel=1&subtype=0"} {"mjpeg_port":"80"} {"snapshot":"/onvif/snapshot?channel=1"}
HOWEVER when I adjust the code to add in the profile token eg cam.getStreamUri({ protocol: 'RTSP' , profileToken: 'profile_1_main'}, (err, stream) => {
I get no streams returned - is this a bug or expected behaviour with the library ?