|
|
|
@ -260,36 +260,19 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
|
|
|
|
start = start.minusMinutes(1);
|
|
|
|
start = start.minusMinutes(1);
|
|
|
|
end = end.minusMinutes(1);
|
|
|
|
end = end.minusMinutes(1);
|
|
|
|
PathUtil.checkDirc(path);
|
|
|
|
PathUtil.checkDirc(path);
|
|
|
|
Duration duration = Duration.between(start, end);
|
|
|
|
|
|
|
|
Long seconds = duration.getSeconds();
|
|
|
|
|
|
|
|
long timeDiff = 90 - seconds;
|
|
|
|
|
|
|
|
if(timeDiff > 0){
|
|
|
|
|
|
|
|
//海康录像时间短会下载失败
|
|
|
|
|
|
|
|
start = start.minusSeconds(timeDiff);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
HCNetSDK.NET_DVR_TIME startTime = new HCNetSDK.NET_DVR_TIME();
|
|
|
|
HCNetSDK.NET_DVR_TIME startTime = new HCNetSDK.NET_DVR_TIME();
|
|
|
|
startTime.setTime(start.getYear(), start.getMonthValue(), start.getDayOfMonth(), start.getHour(), start.getMinute(), start.getSecond());
|
|
|
|
startTime.setTime(start.getYear(), start.getMonthValue(), start.getDayOfMonth(), start.getHour(), start.getMinute(), start.getSecond());
|
|
|
|
HCNetSDK.NET_DVR_TIME endTime = new HCNetSDK.NET_DVR_TIME();
|
|
|
|
HCNetSDK.NET_DVR_TIME endTime = new HCNetSDK.NET_DVR_TIME();
|
|
|
|
endTime.setTime(end.getYear(), end.getMonthValue(), end.getDayOfMonth(), end.getHour(), end.getMinute(), end.getSecond());
|
|
|
|
endTime.setTime(end.getYear(), end.getMonthValue(), end.getDayOfMonth(), end.getHour(), end.getMinute(), end.getSecond());
|
|
|
|
// HCNetSDK.NET_DVR_PLAYCOND struDownloadCond = new HCNetSDK.NET_DVR_PLAYCOND();
|
|
|
|
|
|
|
|
// struDownloadCond.dwChannel = 1;
|
|
|
|
|
|
|
|
// struDownloadCond.struStartTime = startTime;
|
|
|
|
|
|
|
|
// struDownloadCond.struStopTime = endTime;
|
|
|
|
|
|
|
|
// struDownloadCond.write();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("start download mp4 path:{} ,cameraId:{},start_time:{},end_time:{}",path,cameraId,startTime.toStringTime(),endTime.toStringTime());
|
|
|
|
log.info("start download mp4 path:{} ,cameraId:{},start_time:{},end_time:{}",path,cameraId,startTime.toStringTime(),endTime.toStringTime());
|
|
|
|
int lUserID = CameraConnMap.getConnId(cameraId).intValue();
|
|
|
|
int lUserID = CameraConnMap.getConnId(cameraId).intValue();
|
|
|
|
|
|
|
|
|
|
|
|
//int result = HikLoginModuleImpl.hcNetsdk.NET_DVR_GetFileByTime_V40(lUserID,path.getBytes(),struDownloadCond);
|
|
|
|
|
|
|
|
int result = HikLoginModuleImpl.hcNetsdk.NET_DVR_GetFileByTime(lUserID, 1, startTime, endTime, path);
|
|
|
|
int result = HikLoginModuleImpl.hcNetsdk.NET_DVR_GetFileByTime(lUserID, 1, startTime, endTime, path);
|
|
|
|
if (result == -1) {
|
|
|
|
if (result == -1) {
|
|
|
|
log.error("downloadMp4 error code:{},cameraId:{},path:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId,path);
|
|
|
|
log.error("downloadMp4 error code:{},cameraId:{},path:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId,path);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
HikLoginModuleImpl.hcNetsdk.NET_DVR_PlayBackControl(result, HikLoginModuleImpl.hcNetsdk.NET_DVR_PLAYSTART,0,null);
|
|
|
|
HikLoginModuleImpl.hcNetsdk.NET_DVR_PlayBackControl(result, HikLoginModuleImpl.hcNetsdk.NET_DVR_PLAYSTART,0,null);
|
|
|
|
/*if(!ok){
|
|
|
|
|
|
|
|
log.error("downloadMp4 error code:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId);
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
Timer downloadtimer = new Timer();
|
|
|
|
Timer downloadtimer = new Timer();
|
|
|
|
downloadtimer.schedule(new DownloadTask(result,downloadtimer,path,cameraId), 0, 5000);
|
|
|
|
downloadtimer.schedule(new DownloadTask(result,downloadtimer,path,cameraId), 0, 5000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -325,11 +308,11 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
|
|
|
|
HikLoginModuleImpl.hcNetsdk.NET_DVR_StopGetFile(handler);
|
|
|
|
HikLoginModuleImpl.hcNetsdk.NET_DVR_StopGetFile(handler);
|
|
|
|
//ffmpeg转码
|
|
|
|
//ffmpeg转码
|
|
|
|
log.info("download over,cameraId:{}",cameraId);
|
|
|
|
log.info("download over,cameraId:{}",cameraId);
|
|
|
|
/*String ffmpegFile = path+"ffmpeg.mp4";
|
|
|
|
String ffmpegFile = path+"ffmpeg.mp4";
|
|
|
|
convetor(path,ffmpegFile);
|
|
|
|
convetor(path,ffmpegFile);
|
|
|
|
PathUtil.deleteFile(path);
|
|
|
|
PathUtil.deleteFile(path);
|
|
|
|
File file = new File(ffmpegFile);
|
|
|
|
File file = new File(ffmpegFile);
|
|
|
|
file.renameTo(new File(path));*/
|
|
|
|
file.renameTo(new File(path));
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
log.debug("cameraId:{},progress:{}",cameraId,nPos.getValue());
|
|
|
|
log.debug("cameraId:{},progress:{}",cameraId,nPos.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|