对接海康卫视拿取录像回放

 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里进行修改的懒得在创建方法就这样了,直接修改了转换时区的

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值