Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getStreamUri not working correctly on multi channel NVR #328

Open
skarotech opened this issue Jul 16, 2024 · 1 comment
Open

getStreamUri not working correctly on multi channel NVR #328

skarotech opened this issue Jul 16, 2024 · 1 comment

Comments

@skarotech
Copy link

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 + '"}');

// Extract RTSP port
const rtspPort = rtspUrl.port || (rtspUrl.protocol === 'rtsp:' ? 554 : '');
console.log('{"rtsp_port":"' + rtspPort + '"}');

});

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 ?

@RogerHardiman
Copy link
Collaborator

RogerHardiman commented Jul 16, 2024

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants