Commit a7baada6 authored by 周昊's avatar 周昊

Merge branch 'master' into production

# Conflicts:
#	src/main/java/com/censoft/flink/StreamingJob.java
parents dd67bbaf 6fb2909a
......@@ -153,25 +153,6 @@ under the License.
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<!-- ICC鉴权 -->
<dependency>
<groupId>com.dahuatech.icc</groupId>
<artifactId>java-sdk-oauth</artifactId>
<version>1.0.9.1</version>
<exclusions>
<exclusion>
<artifactId>java-sdk-core</artifactId>
<groupId>com.dahuatech.icc</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.dahuatech.icc</groupId>
<artifactId>java-sdk-core</artifactId>
<version>1.0.9.1</version>
</dependency>
</dependencies>
<build>
......
......@@ -8,14 +8,6 @@ import com.censoft.flink.transform.AlgorithmBaseFilterFunction;
import com.censoft.flink.transform.AlgorithmTypeFlatMapFunction;
import com.censoft.flink.transform.ResultExistFilterFunction;
import com.censoft.flink.transform.UpdateLiveFilterFunction;
import com.censoft.flink.utils.RtspToMP4;
import com.dahuatech.hutool.json.JSONObject;
import com.dahuatech.hutool.json.JSONUtil;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.oauth.http.DefaultClient;
import com.dahuatech.icc.oauth.http.IClient;
import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.core.fs.FileSystem;
......@@ -24,9 +16,7 @@ import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -101,8 +91,6 @@ public class StreamingJob {
warnPushBase.setAlarmTime(new Date(algorithmPushDto.getTimeStamp() * 1000));
//获取图片地址
warnPushBase.setPicture("http://172.16.21.3"+algorithmPushDto.getPictureAddress());
//获取视频地址
warnPushBase.setVideo(getVideo("1000790$1$0$0",1698868554L,1698868654L));
warnPushBase.setStatus("wait");
warnPushBase.setSendUserIds("|1|");
warnPushBase.setDelFlag(0);
......
......@@ -28,9 +28,6 @@ public class AlgorithmWarnPushDto {
/** 图片地址 */
private String picture;
/** 视频地址 */
private String video;
/** 处置状态 */
private String status;
......
package com.censoft.flink.utils;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* TODO:
*
* @Author: ZHANG
* @create: 2021/8/27 16:11
*/
public class RtspToMP4 {
public static class In implements Runnable{
private InputStream inputStream;
public In(InputStream inputStream) {
this.inputStream = inputStream;
}
@Override
public void run() {
try {
//转成字符输入流
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "gbk");
int len = -1;
char[] c = new char[1024];
//读取进程输入流中的内容
while ((len = inputStreamReader.read(c)) != -1) {
String s = new String(c, 0, len);
System.out.print(s);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
StartRecord("E:\\ffmpeg\\bin\\ffmpeg.exe","rtsp://192.168.18.203:554/av0_0","D:\\data\\MP4\\3.mp4");
}
public static Process StartRecord(String ffmpegPath, String streamUrl, String FilePath){
ProcessBuilder processBuilder = new ProcessBuilder();
//定义命令内容
List<String> command = new ArrayList<>();
command.add(ffmpegPath);
command.add("-rtsp_transport");
command.add("tcp");
command.add("-y");
command.add("-i");
command.add(streamUrl);
command.add("-c");
command.add("copy");
command.add("-f");
command.add("mp4");
command.add(FilePath);
processBuilder.command(command);
System.out.println("脚本:" + command.toString());
//将标准输入流和错误输入流合并,通过标准输入流读取信息
processBuilder.redirectErrorStream(true);
try {
//启动进程
Process process = processBuilder.start();
System.out.println("开始时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis())));
//获取输入流
InputStream inputStream = process.getInputStream();
Thread inThread = new Thread(new In(inputStream));
inThread.start();
return process;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public boolean stopRecord(Process process) {
try {
OutputStream os = process.getOutputStream();
os.write("q".getBytes());
// 一定要刷新
os.flush();
os.close();
} catch (Exception err) {
err.printStackTrace();
return false;
}
return true;
}
}
#服务地址 端口默认是443
#icc.sdk.host=115.236.17.59:9021
icc.sdk.host=172.16.51.2
#是否启用https访问,默认:是
#icc.sdk.enable.https=false
#认证类型=[client_credentials],[password],client_credentials:客户端鉴权模式;password:用户密码鉴权模式
icc.sdk.grantType=password
#-----------客户端鉴权模式--------------
#客户端鉴权模式申请访问凭证id
icc.sdk.clientId=CompanyName
#客户端鉴权模式申请访问凭证密钥
icc.sdk.clientSecret=67987667-8651-44f1-a3da-f6796e5f23e6
#客户端鉴权模式默认用户,默认是1,超级管理员
#icc.sdk.config.client.userId=1
#-----------用户密码鉴权模式--------------
#用户密码鉴权模式申请访问凭证id
icc.sdk.pwdClientId=CompanyName
#用户密码鉴权模式申请访问凭证密钥
icc.sdk.pwdClientSecret=67987667-8651-44f1-a3da-f6796e5f23e6
#用户名
icc.sdk.username=system
#密码
icc.sdk.password=Admin@123
#http调试模式 false:开启,true:关闭
icc.sdk.enable.https=true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment