增加不使用云端

流媒体按需拉取
球机端口开放
球机辅码流查看下载
dongguan-huaweiyun
LAPTOP-S9HJSOEB\昊天 2 years ago
parent 28b9d3d94a
commit ae32807a96

@ -74,6 +74,7 @@ public class ConfigProperties {
@Data
public static class SavePath{
private Boolean isCloudSave = true;
private Integer saveDays = 30;
private String mediaPath;
private String mp4Path;

@ -182,7 +182,7 @@ public class CameraController {
JSONObject streams = new JSONObject();
cameras.forEach(camera -> {
JSONObject obj = new JSONObject();
obj.put("on_demand",false);
obj.put("on_demand",true);
obj.put("disable_audio",true);
obj.put("url",camera.getRtsp());
streams.put("camera"+camera.getId(),obj);
@ -215,7 +215,7 @@ public class CameraController {
JSONObject streams = new JSONObject();
cameraList.forEach(camera -> {
JSONObject obj = new JSONObject();
obj.put("on_demand",false);
obj.put("on_demand",true);
obj.put("disable_audio",true);
obj.put("url",camera.getRtsp());
streams.put("camera"+camera.getId(),obj);

@ -41,4 +41,6 @@ public class Camera {
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
private Integer rtspPort;
}

@ -252,9 +252,10 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
log.error("pic error:{},cameraId:{}", HikLoginModuleImpl.hcNetsdk.NET_DVR_GetLastError(),cameraId);
}
//上传到云服务器
if(savePath.getIsCloudSave()) {
FtpsUtils ftpsUtils = SpringContextUtil.getBean(FtpsUtils.class);
ftpsUtils.moveFile(true,10, path,savePath.getMediaPath() + path.replace(savePath.getMediaPathCache(),""));
ftpsUtils.moveFile(true, 10, path, savePath.getMediaPath() + path.replace(savePath.getMediaPathCache(), ""));
}
return picResult;
}
@ -278,6 +279,7 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
downloadtimer.schedule(new DownloadTask(result,downloadtimer,path,cameraId,savePath), 0, 5000);
}
}
class DownloadTask extends java.util.TimerTask {
@ -317,10 +319,11 @@ public class HikCameraControlModuleImpl implements CameraControlModule {
PathUtil.deleteFile(path);
File file = new File(ffmpegFile);
file.renameTo(new File(path));
if (savePath.getIsCloudSave()) {
//上传到云服务器
FtpsUtils ftpsUtils = SpringContextUtil.getBean(FtpsUtils.class);
ftpsUtils.moveFile(true,10, path,savePath.getMp4Path() + path.replace(savePath.getMp4PathCache(),""));
ftpsUtils.moveFile(true, 10, path, savePath.getMp4Path() + path.replace(savePath.getMp4PathCache(), ""));
}
}else {
log.debug("cameraId:{},progress:{}",cameraId,nPos.getValue());
}

@ -67,9 +67,8 @@ public class CameraService {
public Integer add(Camera camera) {
camera.setUser(configProperties.getCameraConfig().getCameraUser());
camera.setPassword(configProperties.getCameraConfig().getCameraPassword());
camera.setPort(configProperties.getCameraConfig().getCameraPort());
camera.setUpdateTime(LocalDateTime.now());
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/cam/realmonitor?channel=1&subtype=0");
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":"+camera.getRtspPort()+"/h264/ch1/sub/avstream");
if(StringUtils.isEmpty(camera.getRtcServer())){
camera.setRtcServer("127.0.0.1");
}
@ -89,9 +88,8 @@ public class CameraService {
if(StringUtils.isEmpty(camera.getRtcServer())){
camera.setRtcServer("127.0.0.1");
}
camera.setPort(configProperties.getCameraConfig().getCameraPort());
camera.setUser(configProperties.getCameraConfig().getCameraUser());
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":554/cam/realmonitor?channel=1&subtype=0");
camera.setRtsp("rtsp://"+configProperties.getCameraConfig().getCameraUser()+":"+configProperties.getCameraConfig().getCameraPassword()+"@"+camera.getIp()+":"+camera.getRtspPort()+"/h264/ch1/sub/avstream");
try {
cameraMapper.updateById(camera);
} catch (DuplicateKeyException e) {

@ -76,6 +76,13 @@ public class FtpsUtils {
}
/**
*
* @param flag
* @param count
* @param srcFilePath
* @param targetFilePath
*/
public void moveFile(boolean flag ,int count,
String srcFilePath,
String targetFilePath) {

@ -7,7 +7,7 @@ spring:
maxWait: 60000
minEvictableIdleTimeMillis: 300000
minIdle: 15
password: Leaper@123
password: root
poolPreparedStatements: true
testOnBorrow: true
testOnReturn: false

@ -51,8 +51,10 @@ cameraConfig:
# ------------
# -----图片 mp4下载地址
savePath:
#是否云端保存
isCloudSave: true
saveDays: 1
# 定期删除文件cron解析
# 定期删除文件cron解析
deleteSaveCron: 0 0 0 2 * ?
cloudIp: 121.37.95.190
cloudUser: root
@ -101,3 +103,7 @@ scanCodeMode:
- 14
# 照片 視頻保存多久
deleteFileDays: 365
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

@ -35,3 +35,4 @@ zhehe:
postToken: w89euijon2&UHBTY$%huni34ri
logging:
config: classpath:logback-spring.xml

Loading…
Cancel
Save