public static Object getCameraPlaybackURLs(String cameraIndexCode,String beginTime,String endTime) throws Exception {
ArtemisConfig artemisConfig = new ArtemisConfig();
artemisConfig.setHost("2.22.130.246:443");
artemisConfig.setAppKey("29012484");
artemisConfig.setAppSecret("42wFLX8HOX7VPbLWlos1");
final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs";
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", getCamsApi);
}
};
String contentType = "application/json";
JSONObject jsonBody = new JSONObject();
jsonBody.put("cameraIndexCode", cameraIndexCode);//监控点唯一标识
jsonBody.put("streamform", "ps");
jsonBody.put("recordLocation", "1");
jsonBody.put("beginTime",beginTime);
jsonBody.put("endTime",endTime);
jsonBody.put("lockType", 0);
jsonBody.put("protocol", "ws");//取流协议,“rtsp”:RTSP协议,“rtmp”:RTMP协议,“hls”:HLS协议
jsonBody.put("transmode", 0);//传输协议,0:UDP,1:TCP,默认是TCP
jsonBody.put("expand", "streamform=rtp");//扩展内容,格式:key=value
String body = jsonBody.toJSONString();
String result = ArtemisHttpUtil.doPostStringArtemis(artemisConfig,path, body, null, null, contentType, null);
JSONObject jsonObject = JSON.parseObject(result);
Object list = jsonObject.get("data");
return list;
}
工具类在上一篇文章中对接海康威视平台拿取视频流_artemishttputil_嗯嗯0813的博客-CSDN博客
根据搭建的管理平台去修改对应的请求接口(这里是公司搭建的管理平台)参数注意看就可以拿取到视频流,我拿取的视频流是一个集合这里默认取的第一个url后续修改在改一下
对接海康需要注意时间格式这的时间格式是要求时区的
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startTime = simpleDateFormat.parse(ArtemisUtil.getNextTime(parkingVideoVo.getBeginTime(),7));
Date endTime = simpleDateFormat.parse(ArtemisUtil.getNextTimeOn(parkingVideoVo.getBeginTime(),7));
String sTime = format.format(startTime);
String eTime = format.format(endTime);
我直接在controller里进行修改的懒得在创建方法就这样了,直接修改了转换时区的