PTZ support over Onvif

hi
i seem to have a problem with IP camers and the PTZ over Onvif
the PTZ icon shows up and nothing happen

when i use https://shinobi.video the PTZ works on the camers over Onvif

has anyone else have problems with PTZ over Onvif ?
or it just me

I am having the same issue here, the camera is working fine over ONVIF manager. I will dig more into it and let you know what i find

Currently we do not support ONVIF PTZ. If you know the web commands (ptz?left, etc) then you can manually add those for a PTZ camera.

Thanks

Thank you for the quick response! I will try http post instead.
Do you know if PELCOD is supported?
Thank you again

Actually I had a brain fart, we do have support for PTZ with ONVIF. I’ll have to unpack a ONVIF PTZ camera to test with.

Technically we support Pelco-D but for analog cameras, we don’t have the code base migrated over to IP cameras since most use POST commands or ONVIF.

I am not sure why it is not working over ONVIF…
I captured the wire, i see the HTTP handshaking occurring but the camera is not moving. I have tested multiple camera brands, all of them have the same issue.
is there a way to enable trace log with high verbose on the server side?

I will be writing the adapter to interface with PELCOD over IP, I will share it with the others here if someone want to use it…

Thanks

You can look over https://github.com/bluecherrydvr/bluecherry-apps/blob/01707ac5c04e1a638d17fa2b8891138604a5e72f/www/ajax/media/mediaPtz.php and turn on some logging from the php script itself. I don’t believe there is any debug settings to show PTZ commands over IP.

Please find your lib.php (/usr/share/bluecherry/www/lib) file from bluecherry and replace the moveOnvif function with this one.

with this it works for me, please test and report back.

Edit: I tested the camera I have with ONVIF Device Manager where it worked out of the box and compared the command send from Bluecherry and the ONVIF DM, DM sent the “ContinuousMove” command while Bluecherry sent “RelativeMove”

line: 997 in my file

    private function moveOnvif($command)
    {
            if (is_array($command) && (Inp::get('command') == 'move')) {
                    $speed_pantilt_x = '0.5';
                    $speed_pantilt_y = '0.5';
                    $pantilt_x = 0;
                    $pantilt_y = 0;
                    $zoom = 0;
                    $zoom_speed = '0.5';

                    $xy_value = 5 / 100 ;

                    if ($command['pan'] == 'r') {
                            $pantilt_x = $xy_value;
                    }

                    if ($command['pan'] == 'l') {
                            $pantilt_x = -1 * $xy_value;
                    }

                    if ($command['tilt'] == 'u') {
                            $pantilt_y = $xy_value;
                    }

                    if ($command['tilt'] == 'd') {
                            $pantilt_y = -1 * $xy_value;
                    }

                    if ($command['zoom'] == 't') {
                            $zoom = '0.1';
                    }

                    if ($command['zoom'] == 'w') {
                            $zoom = '-0.1';
                    }
                    $ponvif = new Ponvif();
                    $ponvif->setIPAddress($this->camera->info['ipAddr'] . ':' . $this->camera->info['onvif_port']);
                    $ponvif->setUsername($this->camera->info['rtsp_username']);
                    $ponvif->setPassword($this->camera->info['rtsp_password']);


                    try {
                            $init = $ponvif->initialize();
                            $sources = $ponvif->getSources();

                            if (empty($sources) || $ponvif->isFault($sources)) {
                                    // error
                            } else {
                                    $profileToken = $sources[0][0]['profiletoken'];

                                    if ($pantilt_x || $pantilt_y) {
                                            $ponvif->ptz_ContinuousMove($profileToken, $pantilt_x, $pantilt_y, $speed_pantilt_x, $speed_pantilt_y);
                                    }

                                    if ($zoom) {
                                            $ponvif->ptz_ContinuousMoveZoom($profileToken, $zoom, $zoom_speed);
                                    }
                            }
                    } catch (Exception $e) {
                    }
            } elseif (!is_array($command) && $command == 'stop') {

                    $ponvif = new Ponvif();
                    $ponvif->setIPAddress($this->camera->info['ipAddr'] . ':' . $this->camera->info['onvif_port']);
                    $ponvif->setUsername($this->camera->info['rtsp_username']);
                    $ponvif->setPassword($this->camera->info['rtsp_password']);


                    try {
                            $init = $ponvif->initialize();
                            $sources = $ponvif->getSources();

                            if (empty($sources) || $ponvif->isFault($sources)) {
                                    // error
                            } else {
                                    $profileToken = $sources[0][0]['profiletoken'];

                                    $ponvif->ptz_Stop($profileToken, true, false);
                            }
                    } catch (Exception $e) {
                    }
            }
    }

Thank you, if this resolves @zcworld problem I’ll get the change committed.

@curtishall: thank you.

Also just as a side note, according to Onvif specifications the only move operation that a PTZ capable ONVIF device has to support is the ContinuousMove command, the Relative and AbsoluteMove are optional.

I’m not sure why we used RelativeMove instead of ContinuousMove. My guess is we didn’t want to use continuous movement for analog PTZ and instead wanted to ‘step’.

I don’t have a onvif PTZ connected at the moment, I can set one up later but can you confirm that ‘ContinuousMove’ works in the client and the camera stops when you want it to and doesn’t spin 360 degrees endlessly?

Yes, I tested this via Web interface and also in the Windows client. When a click is released the camera stops moving.
I also tested this via IPCamViewer lite on iOS.

1 Like

Thanks!