Does the ONVIF driver work with devices behind NAT and when port forwarding is used?

Yes, the ONVIF driver can work with devices that are behind NAT but it depends on the configuration of the device. See Configuration of devices behind NAT and port forwarding.