ONVIF, delayed response using PTZ, any other with same issue?

Hi all IP cam fans,

EDIT:
Changed the name of the topic as I have tested and established it is a delay within HA using ONVIF for stream and PTZ control. Would like to know if others can confirm the same behavior? Pressing any control of the PTZ and it takes 4-5 seconds until the image updates inside HA (updates immediately when having IE open next to my HA). Also tested ONVIF Manager and the response upon pressing any PTZ is immediate, concluding it is either the ONVIF in general or my instance itself.


I’ve set up an IP cam using ONVIF to get full control of PTZ and working really good.
Though, I only get a live stream if I use UDP. If switching to TCP I only get an image.

Using UDP makes delays of the PTZ of approx 3 seconds.

Logging on to the cam itself via browser and testing PTZ give immediate response.

Any suggestions on a solution for this ?

BTW; what does the Extra FFMPEG arguments do ?

image

Hi!
Good to hear that PTZ works. Can you please share how you have done it. I have ONVIF setup but PTZ is very jerky and uncontrollable.
Thanks

Hi @cvasantrao,

I use the custom layout-card so I get full control of the sizing of my stream inside a picture-elements card;

      - type: custom:layout-card
        layout: vertical
        column_width: 90%
        cards:

          - type: picture-elements
            title: ""
            camera_view: live
            entity: binary_sensor.videosource_1_motion_alarm
            camera_image: camera.ipnc_mainstream
            elements:
              - type: icon
                icon: 'mdi:arrow-up'
                style:
                  background: 'rgba(255, 255, 255, 0.25)'
                  right: 25px
                  bottom: 50px
                tap_action:
                  action: call-service
                  service: onvif.ptz
                  service_data:
                    entity_id: camera.ipnc_mainstream
                    move_mode: ContinuousMove
                    tilt: UP
              - type: icon
                icon: 'mdi:arrow-down'
                style:
                  background: 'rgba(255, 255, 255, 0.25)'
                  right: 25px
                  bottom: 0px
                tap_action:
                  action: call-service
                  service: onvif.ptz
                  service_data:
                    entity_id: camera.ipnc_mainstream
                    move_mode: ContinuousMove
                    tilt: DOWN
              - type: icon
                icon: 'mdi:arrow-left'
                style:
                  background: 'rgba(255, 255, 255, 0.25)'
                  right: 50px
                  bottom: 25px
                tap_action:
                  action: call-service
                  service: onvif.ptz
                  service_data:
                    entity_id: camera.ipnc_mainstream
                    move_mode: ContinuousMove
                    pan: LEFT
              - type: icon
                icon: 'mdi:arrow-right'
                style:
                  background: 'rgba(255, 255, 255, 0.25)'
                  right: 0px
                  bottom: 25px
                tap_action:
                  action: call-service
                  service: onvif.ptz
                  service_data:
                    entity_id: camera.ipnc_mainstream
                    move_mode: ContinuousMove
                    pan: RIGHT
              - type: icon
                icon: 'mdi:magnify'
                style:
                  background: 'rgba(255, 255, 255, 0.25)'
                  bottom: 25px
                  right: 25px
                tap_action:
                  action: call-service
                  service: onvif.ptz
                  service_data:
                    entity_id: camera.ipnc_mainstream
                    move_mode: ContinuousMove
                    zoom: ZOOM_IN
                hold_action:
                  action: call-service
                  service: onvif.ptz
                  service_data:
                    entity_id: camera.ipnc_mainstream
                    move_mode: ContinuousMove
                    zoom: ZOOM_OUT

Example of how it looks (don’t mind the tilt, it just outside for test at my summer house);

Hi
Thanks for the quick response. It works but with a problem. The camera tilts/pan till the very end. Do you have this issue?

Hi again,

Yes I do have the same problem, but I also face the same problem from the PTZ control of the browser control (plugin) within Internet Explorer. Meaning for me this is not a HA issue but soemthing with the cam control itself. If I click several times fast enough on one of the arrows, it suddenly as you say run to the end.

Do you use UDP or TCP for the ONVIF control ? If you use UDP, do you also experience the delay when sending PTZ commands to the cam?

@cvasantrao Hi again, when you click any of the PTZ arrows, do you have any delay on the update of the image, or is the response immediate?

I tested now with HA and Internet Explorer next to each other and sent the command to pan RIGHT and in Internet Explorer the cam react immediate and image updates, but in HA it takes 5 seconds before I see the update…

Hi TheStigh!
Sorry for the delay in response. Was busy with another project. I am using tcp and the delay is there. But i am more bothered by the cam going all the way to the end. I am not much of a python guy, hence cannot tinker with the component. I tried changing the modes but in vain. Waiting for someone to come up with a solution. Till then I will use the cam’s app to pan and tilt.
Regards