* fix(hikvision): restore two way audio by honoring the body argument
HikvisionCameraAPI.request(urlOrOptions, body) ignored the `body`
argument whenever `urlOrOptions` was an options object. startIntercom()
calls it as request({ url, method, headers }, passthrough), so the audio
PassThrough was silently discarded and the camera received an empty PUT.
Talkback was inaudible and the session tore down almost immediately.
This regressed in 1cd5c194c, which replaced plain `body,` with a
conditional so that callers passing `body` inside the options object
(putVcaResource) would not have it clobbered by the trailing shorthand.
That change ignored the second argument, which startIntercom has used
since fa50d6faa.
Fall back to the second argument when the options object has no body,
which satisfies both call styles.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* docs(hikvision): update Two Way Audio codec support
The Hikvision two way audio option is no longer untested: with the
request body fix in this PR it is confirmed working on real hardware
with both G.711ulaw and G.711alaw.
Also correct the claim that any codec other than G.711ulaw fails.
G.711alaw works; startIntercom has mapped it to pcm_alaw for some time.
Non-G.711 codecs (AAC) remain unsupported - startIntercom logs
"Unknown codec" and falls back to pcm_mulaw, so the camera receives
mu-law it cannot decode and plays nothing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Hikvision Plugin for Scrypted
The Hikvision Plugin brings Hikvision-branded cameras, doorbells or NVR devices that are IP-based into Scrypted. Most commonly this plugin is used with 2 plugins: Rebroadcast and HomeKit.
Device must have built-in motion detection (most Hikvision cameras or NVRs have this).
If the camera or NVR do not have motion detection, you will have to use a separate plugin or device to achieve this (e.g., opencv, pam-diff, or dummy-switch) and group it to the camera.
Two Way Audio
There are two options for Two Way Audio:
- ONVIF (Recommended)
- Hikvision
Two Way Audio is supported if the audio codec is set to G.711ulaw or G.711alaw on the camera. G.711ulaw is usually the default audio codec, and will also work with HomeKit.
The Hikvision option uses the camera's ISAPI two way audio endpoint, and is confirmed working with both G.711ulaw and G.711alaw.
Audio codecs other than G.711 (such as AAC) are not supported for Two Way Audio. The plugin will log Unknown codec and fall back to G.711ulaw, which results in no audio from the camera speaker.
Codec Settings
Configure optimal codec settings (as required by HomeKit) through Hikvision's configuration webpage or device interface (not Scrypted).
Hikvision's iVMS 4200 software, or similar, may be utilized to configure device as well as create a motion detection grid (required for motion detection and hardware dependent).
Generally, for newer devices the main stream (Stream 1) may be incompatible with HomeKit as it only outputs HEVC. Configure and specify a substream instead (Stream 2 or 3).
The optimal/reliable codec settings can be found in the documentation for the Homekit Plugin.
Hikvision NVR
Cameras attached or recording through a Hikvision NVR (IP-based) can be used in Hikvision Plugin for Scrypted. Each 'Channel' or (camera) Device attached to the NVR must be configured as separate Device in Hikvision plugin. The Channel number is the hundreds digit and (sub-)stream is ones digit:
- 101 = Camera 1 (1xx), stream 1 (xx1 = main stream)
- 102 = Camera 1 (1xx), stream 2 (xx2 = sub-stream 1)
- 203 = Camera 2 (2xx), stream 3 (xx3 = sub-stream 2)
NOTE: Snapshots may be inconsistent if using an NVR. A workaround exists if you can access your camera on network without going through NVR (see below Snapshot URL Override). If you can only access your camera through an NVR, then snapshots may not be supported.
IP AddressNVR's IP AddressSnapshot URL Overridecamera's IP address (preferred) or specific port number of NVR for that camera (may work). That is:http://<camera ip address>/ISAPI/Streaming/channels/<channel number>/pictureorhttp://<NVR IP address>:<NVR port # for channel>/ISAPI/Streaming/channels/<channel number>/picture. 720p snapshots seem to be more stable than 1080p or higher:http://<NVR IP address>/ISAPI/Streaming/channels/<channel number>/picture?videoResolutionWidth=1280&videoResolutionHeight=720HTTP Port Overridecheck your NVR device settings (it may be1080instead of80)Channel Number Overridecamera's channel number as known to DVR (i.e., 101, 102, 103, etc.)Default StreamProperly configured video codec stream (Main Stream =Stream 1; Sub Stream 1 =Stream 2; Sub Stream 2 =Stream 3; and so on)
Troubleshooting
General
- Not receiving motion alerts in the device's Scrypted event log? Check all of the following: (1) device has a motion detection grid drawn and enabled, (2) user or group access permissions of account used for device (3) do not use self-signed certs for HTTPS on the device, (4)
CGIandISAPIintegration protocol/service on device is enabled, and (5) that the authentication method on the device is set to "digest". - If device has HTTPS enabled, try disabling HTTPS on the device to see if that resolves issue (do not use self-signed certs).
- If device has enabled user lockout, max connections, concurrent requests, etc., try disabling and/or increasing to max allowed for troubleshooting.
- Does your account (
Username) have proper user and/or group permissions? Try granting all permissions for testing. - Screenshots not working? Check that (1)
CGIprotocol is enabled in device settings (may be located at Network->Advanced Settings->Integration Protocol) and (2) lower Snapshot resolution with anOverride Snapshot URL(above) to request a lower resolution snapshot (i.e. 720p or lower). - Check that you have specified the correct
Default Streamnumber in device (in Scrypted). - Check that you have configured the correct Stream number's codec settings (in Hikvision's configuration page (Main Stream or Sub Stream(s)).
User Account Permission (Camera or NVR)
If you have a non-owner/admin user account setup on your cameras and/or NVR, then the account's access permissions must be sufficient to expose motion events/alerts, playback, and snapshot. Depending on device type, at minimum this may require the following permissions:
alertStreamPlaybackandLive ViewEvent/Notificationoperator(user group)