28181接入网关查询NVR录像文件

2 篇文章 0 订阅

使用公安spvmn的调测软件测试,下发如下命令:

<?xml version="1.0"?>
<Query>
<CmdType>RecordInfo</CmdType>
<SN>17430</SN>
<DeviceID>34020000001110000001</DeviceID>
<StartTime>2016-05-11T19:46:17</StartTime>
<EndTime>2016-05-12T19:46:17</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Query>

为了方便我将nvr的ID改为111,按编码规则应该是118,发送上述命令后,设备返回:

MESSAGE sip:34020000001310000001@34020000 SIP/2.0
Call-ID: 476f5bf59ea9c50a629d97729192d340@0.0.0.0
CSeq: 1 MESSAGE
From: <sip:34020000002000000001@34020000>;tag=60103465_53173353_1f01e42a-5ce4-4790-9243-7e7901a6f01c
To: <sip:34020000001310000001@34020000>
Max-Forwards: 70
Content-Type: Application/MANSCDP+xml
Route: <sip:34020000001310000001@10.60.1.245:5060;lr>
Via: SIP/2.0/UDP 10.60.1.189:5060;branch=z9hG4bK1f01e42a-5ce4-4790-9243-7e7901a6f01c_53173353_7406162174963
Content-Length: 255

<?xml version="1.0"?>
<Query>
<CmdType>RecordInfo</CmdType>
<SN>17430</SN>
<DeviceID>34020000001110000001</DeviceID>
<StartTime>2016-05-11T19:46:17</StartTime>
<EndTime>2016-05-12T19:46:17</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Query>
SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 10.60.1.189:5060;branch=z9hG4bK1f01e42a-5ce4-4790-9243-7e7901a6f01c_53173353_7406162174963
From: <sip:34020000002000000001@34020000>;tag=60103465_53173353_1f01e42a-5ce4-4790-9243-7e7901a6f01c
To: <sip:34020000001310000001@34020000>;tag=404651674
Call-ID: 476f5bf59ea9c50a629d97729192d340@0.0.0.0
CSeq: 1 MESSAGE
User-Agent: Embedded Net DVR/NVR/DVS
Content-Length: 0

设备回了一个不能识别,说明这样发送是有点问题的,NVR绑定了两个IPC,需要设置通道编码ID,查录像文件应该是按通道ID来查,而不是按NVR,不然会出错。


不是发NVR的id,而是发送通道ID,往哪里发呢,当然是往NVR的地址了,具体如下:

<?xml version="1.0"?>
<Query>
<CmdType>RecordInfo</CmdType>
<SN>17430</SN>
<DeviceID>34020000001310000004</DeviceID>
<StartTime>2016-05-11T19:46:17</StartTime>
<EndTime>2016-05-12T19:46:17</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Query>

设备返回:
MESSAGE sip:34020000001310000001@34020000 SIP/2.0
Call-ID: f79c14a8538a96e8111d88ad383022bd@0.0.0.0
CSeq: 1 MESSAGE
From: <sip:34020000002000000001@34020000>;tag=84598796_53173353_1f01e42a-5ce4-4790-9243-7e7901a6f01c
To: <sip:34020000001310000001@34020000>
Max-Forwards: 70
Content-Type: Application/MANSCDP+xml
Route: <sip:34020000001310000001@10.60.1.245:5060;lr>
Via: SIP/2.0/UDP 10.60.1.189:5060;branch=z9hG4bK1f01e42a-5ce4-4790-9243-7e7901a6f01c_53173353_7887086612904
Content-Length: 255

<?xml version="1.0"?>
<Query>
<CmdType>RecordInfo</CmdType>
<SN>17430</SN>
<DeviceID>34020000001310000004</DeviceID>
<StartTime>2016-05-11T19:46:17</StartTime>
<EndTime>2016-05-12T19:46:17</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Query>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.60.1.189:5060;branch=z9hG4bK1f01e42a-5ce4-4790-9243-7e7901a6f01c_53173353_7887086612904
From: <sip:34020000002000000001@34020000>;tag=84598796_53173353_1f01e42a-5ce4-4790-9243-7e7901a6f01c
To: <sip:34020000001310000001@34020000>;tag=463233309
Call-ID: f79c14a8538a96e8111d88ad383022bd@0.0.0.0
CSeq: 1 MESSAGE
User-Agent: Embedded Net DVR/NVR/DVS
Content-Length: 0


MESSAGE sip:34020000002000000001@3402000000 SIP/2.0
Via: SIP/2.0/UDP 10.60.1.245:5060;rport=5060;branch=z9hG4bK1291769096;received=10.60.1.245
From: <sip:34020000001110000001@3402000000>;tag=536001771
To: <sip:34020000002000000001@3402000000>
Call-ID: 1953755354
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: Embedded Net DVR/NVR/DVS
Content-Length: 2964

<?xml version="1.0"?>
<Response>
<CmdType>RecordInfo</CmdType>
<SN>17430</SN>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<SumNum>15</SumNum>
<RecordList Num="10">
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462966268_1462968241</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T19:31:08</StartTime>
<EndTime>2016-05-11T20:04:01</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462968250_1462971411</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T20:04:10</StartTime>
<EndTime>2016-05-11T20:56:51</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462971418_1462971796</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T20:56:58</StartTime>
<EndTime>2016-05-11T21:03:16</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462971736_1462971791</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T21:02:16</StartTime>
<EndTime>2016-05-11T21:03:11</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462971858_1462975248</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T21:04:18</StartTime>
<EndTime>2016-05-11T22:00:48</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462975253_1462978311</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T22:00:53</StartTime>
<EndTime>2016-05-11T22:51:51</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462978317_1462980934</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T22:51:57</StartTime>
<EndTime>2016-05-11T23:35:34</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462980941_1462984455</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-11T23:35:41</StartTime>
<EndTime>2016-05-12T00:34:15</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462984461_1462988287</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T00:34:21</StartTime>
<EndTime>2016-05-12T01:38:07</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462988296_1462992080</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T01:38:16</StartTime>
<EndTime>2016-05-12T02:41:20</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
</RecordList>
</Response>

SIP/2.0 200 OK
To: <sip:34020000002000000001@3402000000>;tag=19640308_53173353_362b2cba-f607-44f6-a970-7671a73bc4ef
Via: SIP/2.0/UDP 10.60.1.245:5060;rport=5060;branch=z9hG4bK1291769096;received=10.60.1.245
CSeq: 20 MESSAGE
Call-ID: 1953755354
From: <sip:34020000001110000001@3402000000>;tag=536001771
Content-Length: 0


MESSAGE sip:34020000002000000001@3402000000 SIP/2.0
Via: SIP/2.0/UDP 10.60.1.245:5060;rport=5060;branch=z9hG4bK1023085277;received=10.60.1.245
From: <sip:34020000001110000001@3402000000>;tag=1951781126
To: <sip:34020000002000000001@3402000000>
Call-ID: 1296376675
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: Embedded Net DVR/NVR/DVS
Content-Length: 1588

<?xml version="1.0"?>
<Response>
<CmdType>RecordInfo</CmdType>
<SN>17430</SN>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<SumNum>15</SumNum>
<RecordList Num="5">
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462992081_1462995940</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T02:41:21</StartTime>
<EndTime>2016-05-12T03:45:40</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462995949_1462999775</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T03:45:49</StartTime>
<EndTime>2016-05-12T04:49:35</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1462999783_1463003096</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T04:49:43</StartTime>
<EndTime>2016-05-12T05:44:56</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1463003096_1463015058</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T05:44:56</StartTime>
<EndTime>2016-05-12T09:04:18</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
<Item>
<DeviceID>34020000001310000004</DeviceID>
<Name>IPCamera 01</Name>
<FilePath>1463015058_1463020210</FilePath>
<Address>Address 1</Address>
<StartTime>2016-05-12T09:04:18</StartTime>
<EndTime>2016-05-12T10:30:10</EndTime>
<Secrecy>0</Secrecy>
<Type>time</Type>
</Item>
</RecordList>
</Response>

SIP/2.0 200 OK
To: <sip:34020000002000000001@3402000000>;tag=34859437_53173353_272146f9-97d1-4332-8f56-10a9088fd18a
Via: SIP/2.0/UDP 10.60.1.245:5060;rport=5060;branch=z9hG4bK1023085277;received=10.60.1.245
CSeq: 20 MESSAGE
Call-ID: 1296376675
From: <sip:34020000001110000001@3402000000>;tag=1951781126
Content-Length: 0

这样就可以查到NVR的录像文件了

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 你可以使用以下代码示例来查询NVR录像文件:String url = "http://your_nvr_ip/isapi/record/query";HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url);// Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("command", "query")); nameValuePairs.add(new BasicNameValuePair("recordType", "all")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));// Execute HTTP Post Request HttpResponse response = httpclient.execute(httppost); ### 回答2: 以下是一个使用Java代码查询NVR录像文件的例子: ```java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class ISAPIMain { public static void main(String[] args) { try { // 设置NVR的IP地址和端口号 String nvrIpAddress = "192.168.0.100"; int nvrPort = 80; // 设置查询录像文件的URL String queryUrl = "http://" + nvrIpAddress + ":" + nvrPort + "/isapi/record/tracks"; // 创建URL对象 URL url = new URL(queryUrl); // 创建HttpURLConnection对象 HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // 设置请求方法 connection.setRequestMethod("GET"); // 发送请求并获取响应状态码 int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { // 读取响应数据 BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; StringBuilder response = new StringBuilder(); // 逐行读取数据 while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); // 对返回的JSON数据进行处理 String jsonResponse = response.toString(); // 在这里可以对JSON数据进行解析和处理 // 输出查询结果 System.out.println("查询结果:" + jsonResponse); } else { System.out.println("查询失败,错误代码:" + responseCode); } // 断开连接 connection.disconnect(); } catch (Exception e) { e.printStackTrace(); } } } ``` 以上代码以GET方法发送一个HTTP请求到指定的NVR IP地址和端口号,获取记录文件的列表。代码使用`HttpURLConnection`类发送请求并获取响应数据,在读取响应数据之后,可以对返回的JSON数据进行解析和处理。请根据具体情况替换NVR的IP地址和端口号,并对返回的JSON数据进行适当的处理。 ### 回答3: isapi是一种用于网络视频监控设备的通信协议,通过该协议可以实现与网络视频录像机(NVR)的通信。在Java中,我们可以使用HttpClient库来构建一个基于isapi查询NVR录像文件的代码。 首先,我们需要引入HttpClient库的相依赖: ```java <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.12</version> </dependency> ``` 然后,我们可以编写如下的Java代码示例: ```java import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; public class IsapiQueryExample { public static void main(String[] args) { String nvrIp = "192.168.0.1"; // NVR的IP地址 String username = "admin"; // NVR的用户名 String password = "password"; // NVR的密码 String isapiUrl = "http://" + nvrIp + "/ISAPI/Streaming/tracks/101"; // NVR的isapi查询接口URL,这里查询通道101的录像文件列表 // 创建HttpClient实例 HttpClient httpClient = HttpClientBuilder.create().build(); // 创建HttpGet请求,并设置用户名和密码以及isapi查询URL HttpGet httpGet = new HttpGet(isapiUrl); httpGet.setHeader("Authorization", "Basic " + base64Encode(username + ":" + password)); try { // 执行请求,获得响应 HttpResponse response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); // 解析响应的内容 if (entity != null) { String responseContent = EntityUtils.toString(entity); System.out.println("Response content: " + responseContent); } } catch (Exception e) { e.printStackTrace(); } } // 对用户名和密码进行Base64编码 public static String base64Encode(String str) { return Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8)); } } ``` 以上代码示例只是简单地演示了如何使用Java代码通过isapi查询NVR录像文件。实际的isapi查询接口URL和用户名、密码应根据具体情况进行修改和设置。此外,还可能需要解析响应内容并进行业务处理,这里只是将响应内容输出到控制台。 希望以上代码示例能对您有所帮助。请注意,在实际使用时,请根据具体的设备和接口文档进行调整和设置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值