To upload and display metadata on the video without using Hikvision PlayCtrl SDK, we provide a solution based on ISAPI integration and RTSP.
RTSP is an international protocol, so for its definition, search for the related manuals or specifications in the library or on the network for reference.
The device capability is returned in the message XML_DeviceCap.
If the node <isSupportMetadata> is returned in the message, it indicates that the device supports metadata, and you can perform the following steps.
Otherwise, it indicates that metadata is not supported by device, please end this task.
You can also call /ISAPI/Streaming/channels/<ID>/Metadata/<type> by PUT method to configure parameters for a specific metadata type.
Sample URL for getting stream for live view by RTSP method: DESCRIBE rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0
DESCRIBE rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0 CSeq:0 Accept:application/sdp Authorization: User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 401 Unauthorized CSeq: 0 WWW-Authenticate: Digest realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", stale="FALSE" Date: Mon, Dec 18 2017 04:37:30 GMT DESCRIBE rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0 CSeq:0 Accept:application/sdp Authorization:Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101", response="99b683462210bd819c8d6bafb39dd262" User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 200 OK CSeq: 0 Content-Type: application/sdp Content-Length: 737 v=0 o=- 1513571850040093 1513571850040093 IN IP4 10.10.36.212 s=Media Presentation e=NONE b=AS:5100 t=0 0 a=control:* m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:5000 a=recvonly a=x-dimensions:1920,1080 a=control:trackID=1 a=rtpmap:96 H264/90000 a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z00AKp2oHgCJ+WbgICAoAAADAAgAAAMBlCA=,aO48gA== m=audio 0 RTP/AVP 0 c=IN IP4 0.0.0.0 b=AS:50 a=recvonly a=control:trackID=2 a=rtpmap:0 PCMU/8000 m=application 0 RTP/AVP 107 c=IN IP4 0.0.0.0 b=AS:50 a=recvonly a=control:trackID=3 a=rtpmap:107 isapi.metadata/90000 a=Media_header:MEDIAINFO=494D4B48010200000400000110710110401F000000FA000000000000000000000000000000000000; a=appversion:1.0
The "a=rtpmap:107 isapi.metadata/90000" in the stream information indicates that the stream contains metadata information, and the "trackID=3" refers to the metadata ID which is used to get the detailed metadata information in step 7.
An example for getting detailed metadata information by SETUP method is shown below for reference.
SETUP rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101/trackID=3 RTSP/1.0 Seq:3 Authorization:Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101", response="46b39a563fd9977eff83067adc4e587b" Session: 408703626 Transport: RTP/AVP/TCP;unicast; User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 200 OK Session: 408703626;timeout=60 Transport: RTP/AVP/TCP;unicast;interleaved=6-7;ssrc=14b37590;mode="play" Date: Mon, Dec 18 2017 04:37:30 GMT
Metadata information can be sent with the stream, or alone in the response of RTSP request (must be packaged by RTP), see the format and structure of metadata message to be uploaded in XML_Video_Metadata or JSON_Metadata.
Sample URL for starting live view by RTSP method: PLAY rtsp://10.10.36.160:554/ISAPI/Streaming/channels/102 RTSP/1.0. And then device starts uploading the RTP packet which contains stream data and metadata (see the message example below).
PLAY rtsp://10.10.36.160:554/ISAPI/Streaming/channels/102 RTSP/1.0 CSeq:4 Authorization:Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.160:554/ISAPI/Streaming/channels/102", response="611cc58b1b42b8df909b57b737a7ad3a" Session: 408703626 Range:npt=0.000000- Scale:1.000 User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 200 OK CSeq: 4 Session: 408703626 RTP-Info: url=trackID=1;seq=24874,url=trackID=2;seq=42360,url=trackID=3;seq=0 Date: Mon, Dec 18 2017 04:37:31 GMT $.....@..n..Ufw.<?xml version="1.0" encoding="UTF-8"?> <Metadata version="1.0" xmlns="http://www.isapi.org/ver20/XMLSchema"> <type>ruleTarget</type> <subType>behaviorAnalysis</subType> <time>2017-12-18T04:37:31.000+0800</time> <DevInfo> <ipAddress>10.10.36.212</ipAddress> <portNo>554</portNo> <macAddress>31:30:2e:31:30:2e</macAddress> <channel>1</channel> <domainName></domainName> </DevInfo> <TargetDetection> <TargetList></TargetList> </TargetDetection> </Metadata>
If the type value of current RTP packet is 0x6b, it indicates that the packet contains metadata, and perform the following steps.
If the type value of current RTP packet is not 0x6b, get the next packet and judge again.
TEARDOWN rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0 CSeq:4 Authorization: Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101", response="2822238cec4028c34749cf3a48ce7519" Session:408703626;timeout=60 User-Agent:NKPlayer-VSPlayer1.0
To upload and display metadata on the video without using Hikvision PlayCtrl SDK, we provide a solution based on ISAPI integration and RTSP.
RTSP is an international protocol, so for its definition, search for the related manuals or specifications in the library or on the network for reference.
The device capability is returned in the message XML_DeviceCap.
If the node <isSupportMetadata> is returned in the message, it indicates that the device supports metadata, and you can perform the following steps.
Otherwise, it indicates that metadata is not supported by device, please end this task.
You can also call /ISAPI/Streaming/channels/<ID>/Metadata/<type> by PUT method to configure parameters for a specific metadata type.
Sample URL for getting stream for live view by RTSP method: DESCRIBE rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0
DESCRIBE rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0 CSeq:0 Accept:application/sdp Authorization: User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 401 Unauthorized CSeq: 0 WWW-Authenticate: Digest realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", stale="FALSE" Date: Mon, Dec 18 2017 04:37:30 GMT DESCRIBE rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0 CSeq:0 Accept:application/sdp Authorization:Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101", response="99b683462210bd819c8d6bafb39dd262" User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 200 OK CSeq: 0 Content-Type: application/sdp Content-Length: 737 v=0 o=- 1513571850040093 1513571850040093 IN IP4 10.10.36.212 s=Media Presentation e=NONE b=AS:5100 t=0 0 a=control:* m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:5000 a=recvonly a=x-dimensions:1920,1080 a=control:trackID=1 a=rtpmap:96 H264/90000 a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z00AKp2oHgCJ+WbgICAoAAADAAgAAAMBlCA=,aO48gA== m=audio 0 RTP/AVP 0 c=IN IP4 0.0.0.0 b=AS:50 a=recvonly a=control:trackID=2 a=rtpmap:0 PCMU/8000 m=application 0 RTP/AVP 107 c=IN IP4 0.0.0.0 b=AS:50 a=recvonly a=control:trackID=3 a=rtpmap:107 isapi.metadata/90000 a=Media_header:MEDIAINFO=494D4B48010200000400000110710110401F000000FA000000000000000000000000000000000000; a=appversion:1.0
The "a=rtpmap:107 isapi.metadata/90000" in the stream information indicates that the stream contains metadata information, and the "trackID=3" refers to the metadata ID which is used to get the detailed metadata information in step 7.
An example for getting detailed metadata information by SETUP method is shown below for reference.
SETUP rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101/trackID=3 RTSP/1.0 Seq:3 Authorization:Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101", response="46b39a563fd9977eff83067adc4e587b" Session: 408703626 Transport: RTP/AVP/TCP;unicast; User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 200 OK Session: 408703626;timeout=60 Transport: RTP/AVP/TCP;unicast;interleaved=6-7;ssrc=14b37590;mode="play" Date: Mon, Dec 18 2017 04:37:30 GMT
Metadata information can be sent with the stream, or alone in the response of RTSP request (must be packaged by RTP), see the format and structure of metadata message to be uploaded in XML_Video_Metadata or JSON_Metadata.
Sample URL for starting live view by RTSP method: PLAY rtsp://10.10.36.160:554/ISAPI/Streaming/channels/102 RTSP/1.0. And then device starts uploading the RTP packet which contains stream data and metadata (see the message example below).
PLAY rtsp://10.10.36.160:554/ISAPI/Streaming/channels/102 RTSP/1.0 CSeq:4 Authorization:Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.160:554/ISAPI/Streaming/channels/102", response="611cc58b1b42b8df909b57b737a7ad3a" Session: 408703626 Range:npt=0.000000- Scale:1.000 User-Agent:NKPlayer-VSPlayer1.0 RTSP/1.0 200 OK CSeq: 4 Session: 408703626 RTP-Info: url=trackID=1;seq=24874,url=trackID=2;seq=42360,url=trackID=3;seq=0 Date: Mon, Dec 18 2017 04:37:31 GMT $.....@..n..Ufw.<?xml version="1.0" encoding="UTF-8"?> <Metadata version="1.0" xmlns="http://www.isapi.org/ver20/XMLSchema"> <type>ruleTarget</type> <subType>behaviorAnalysis</subType> <time>2017-12-18T04:37:31.000+0800</time> <DevInfo> <ipAddress>10.10.36.212</ipAddress> <portNo>554</portNo> <macAddress>31:30:2e:31:30:2e</macAddress> <channel>1</channel> <domainName></domainName> </DevInfo> <TargetDetection> <TargetList></TargetList> </TargetDetection> </Metadata>
If the type value of current RTP packet is 0x6b, it indicates that the packet contains metadata, and perform the following steps.
If the type value of current RTP packet is not 0x6b, get the next packet and judge again.
TEARDOWN rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101 RTSP/1.0 CSeq:4 Authorization: Digest username="admin", realm="IP Camera(51289)", nonce="9fe43f1322976c0aa218b0f23f554b44", uri="rtsp://10.10.36.212:554/ISAPI/Streaming/channels/101", response="2822238cec4028c34749cf3a48ce7519" Session:408703626;timeout=60 User-Agent:NKPlayer-VSPlayer1.0