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

ONVIF Probe and AutoConfigure does not return anything #664

Open
curtishall opened this issue Feb 23, 2024 · 1 comment
Open

ONVIF Probe and AutoConfigure does not return anything #664

curtishall opened this issue Feb 23, 2024 · 1 comment
Assignees

Comments

@curtishall
Copy link
Member

We need to use the new onvif (nodejs) function to pull json, the old onvif_tool binary no longer functions with most newer onvif standards:

$ /usr/lib/bluecherry/onvif_tool 192.168.86.200 login password get_stream_urls

http://192.168.86.200/onvif/Media
Oops, something went wrong:
SOAP 1.2 fault SOAP-ENV:Sender[no subcode]
"Validation constraint violation: invalid value in element 'tt:Encoding'"
Detail: [no detail]

https://github.com/bluecherrydvr/bluecherry-apps/blob/31fdffcd61fc178c05da566cc66887937cf004f8/www/ajax/addip.php#L72C15-L95

@curtishall
Copy link
Member Author

example code to get rtsp paths (nodejs)

const onvif = require('onvif');

// Extract command-line arguments
const args = process.argv.slice(2); // Skip the first two elements
const HOST_PORT = args[0];  // IP address and port (optional)
const USERNAME = args[1];  // Username
const PASSWORD = args[2];  // Password

// Split HOST_PORT by ':' to separate IP and port
const [HOST, PORT] = HOST_PORT.split(':');

// Default ONVIF port if not specified
const DEFAULT_PORT = 80;

// Validate input arguments
if (!HOST || !USERNAME || !PASSWORD) {
  console.error('Usage: node getRtspUrls.js <ip_address[:port]> <username> <password>');
  process.exit(1);
}

// Connect to the ONVIF camera
const camera = new onvif.Cam({
  hostname: HOST,
  username: USERNAME,
  password: PASSWORD,
  port: PORT || DEFAULT_PORT,  // Use the specified port or default if not provided
}, function(err) {
  if (err) {
    return console.error(err);
  }

  // Get all the available media profiles
  this.getProfiles((err, profiles) => {
    if (err) {
      return console.error(err);
    }

    // Fetch and output RTSP URLs for each profile
    const rtspUrls = profiles.map(profile => {
      return new Promise((resolve, reject) => {
        this.getStreamUri({protocol: 'RTSP', profileToken: profile.token}, (err, stream) => {
          if (err) {
            reject(err);
          } else {
            resolve({profileName: profile.name, rtspUri: stream.uri});
          }
        });
      });
    });

    Promise.all(rtspUrls)
      .then(urls => {
        console.log(JSON.stringify(urls, null, 2));
      })
      .catch(error => console.error(error));
  });
});

andrey-utkin added a commit to andrey-utkin/bluecherry-apps that referenced this issue Feb 29, 2024
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