@@ -26,8 +26,9 @@ public class DefaultOutHandlerMethod implements OutHandlerMethod{ | |||
isBroken=true; | |||
}else if(msg.indexOf("miss")!= -1) { | |||
log.info(id + "任务可能发生丢包:" + msg); | |||
log.info("失败,设置中断状态"); | |||
isBroken=true; | |||
//log.info("失败,设置中断状态"); | |||
//isBroken=true; | |||
isBroken=false; | |||
}else if(msg.indexOf("occurred")!= -1) { | |||
log.info(id + "任务可能发生丢包10054:" + msg); | |||
log.info("失败,设置中断状态"); |
@@ -22,7 +22,7 @@ public class FFrtmpServer implements ApplicationRunner { | |||
@Override | |||
public void run(ApplicationArguments args) { | |||
try { | |||
/* CommandManager manager = new CommandManagerImpl(); | |||
/*CommandManager manager = new CommandManagerImpl(); | |||
// -rtsp_transport tcp | |||
//测试多个任何同时执行和停止情况 | |||
//false表示使用配置文件中的ffmpeg路径,true表示本条命令已经包含ffmpeg所在的完整路径 | |||
@@ -31,19 +31,19 @@ public class FFrtmpServer implements ApplicationRunner { | |||
//manager.start("tomcat1", "ffmpeg -i rtsp://192.168.144.25:554/stream=0 -vcodec copy -acodec copy -f flv -y rtmp://221.226.114.142:19350/rlive/stream_11?sign=rHtBg3sz",false); | |||
if (cmdParam.getType()==1) { | |||
manager.start("test0", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", cmdParam.getPlayUrl()) | |||
.add("-rtsp_transport","tcp") | |||
.add("ffmpeg") | |||
.add("-rtsp_transport","tcp").add("-i", cmdParam.getPlayUrl()) | |||
.add("-vcodec","copy") | |||
.add("-acodec","copy") | |||
.add("-f","flv") | |||
.add("-b:v", "2M") | |||
.add("-maxrate", "2M") | |||
.add("-bufsize", "1M") | |||
.add("-bufsize", "4M") | |||
.add("-y").add(cmdParam.getPushUrl())); | |||
}else if (cmdParam.getType()==3) { | |||
manager.start("test1", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", cmdParam.getPlayUrl()) | |||
.add("-rtsp_transport","tcp") | |||
.add("ffmpeg") | |||
.add("-rtsp_transport","tcp").add("-i", cmdParam.getPlayUrl()) | |||
.add("-vcodec","copy") | |||
.add("-acodec","copy") | |||
.add("-f","flv") | |||
@@ -53,8 +53,8 @@ public class FFrtmpServer implements ApplicationRunner { | |||
.add("-y").add(cmdParam.getPushUrl())); | |||
Thread.sleep(5000); | |||
manager.start("test2", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i",cmdParam.getPlayUrl()) | |||
.add("-rtsp_transport","tcp") | |||
.add("ffmpeg") | |||
.add("-rtsp_transport","tcp").add("-i",cmdParam.getPlayUrl()) | |||
.add("-vcodec","copy") | |||
.add("-acodec","copy") | |||
.add("-f","flv") | |||
@@ -65,8 +65,8 @@ public class FFrtmpServer implements ApplicationRunner { | |||
}else if (cmdParam.getType()==4){ | |||
//单进程 多路 | |||
manager.start("test4", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", cmdParam.getPlayUrl()) | |||
.add("-rtsp_transport", "tcp") | |||
.add("ffmpeg") | |||
*//*.add("-rtsp_transport", "tcp")*//*.add("-i", cmdParam.getPlayUrl()) | |||
.add("-vcodec", "copy") | |||
.add("-acodec", "copy") | |||
.add("-b:v", "2M") |
@@ -14,16 +14,16 @@ public class MqttLiveHandle { | |||
@Autowired | |||
private RtmpLiveService rtmpLiveService; | |||
public void handleLive(final String topic, MqttMessage message){ | |||
public void handleLive(final String topic, MqttMessage message) throws InterruptedException { | |||
String objmsg = new String(message.getPayload()); | |||
final JSONObject jsonObject = JSONObject.parseObject(objmsg); | |||
if (topic.contains("rtmp/live")) { | |||
if (!ObjectUtils.isEmpty(jsonObject.get("command"))) { | |||
String cmdoperat = jsonObject.get("command").toString(); | |||
if (cmdoperat.equals("start")) { | |||
Thread.sleep(15000); | |||
Thread thread = new Thread(new Runnable() { | |||
String code = jsonObject.get("code") == null ? topic.split("/")[2] : jsonObject.get("code").toString(); | |||
public void run() { | |||
try { | |||
rtmpLiveService.pushServer(code); | |||
@@ -45,6 +45,7 @@ public class MqttLiveHandle { | |||
String boolbms = cmdoperat.getString("Power"); | |||
log.info("boolbms:",jsonObject.get("Power")); | |||
if (boolbms.equals("on")) { | |||
Thread.sleep(15000); | |||
Thread thread = new Thread(new Runnable() { | |||
String code = jsonObject.get("code") == null ? topic.split("/")[2] : jsonObject.get("code").toString(); | |||
public void run() { |
@@ -51,6 +51,7 @@ public class RtmpLiveService { | |||
log.info("任务运行中"); | |||
return; | |||
} | |||
//Thread.sleep(5000); | |||
String pushUrl = ""; | |||
if (cmdParam.getType() == 2) { | |||
log.info("获取流媒体通道"); | |||
@@ -87,10 +88,10 @@ public class RtmpLiveService { | |||
try { | |||
String reTopic = cmdParam.getMqttTopic().replace("live", "result"); | |||
String taskId = manager.start("test1", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", playUrl) | |||
.add("-rtsp_transport", "tcp") | |||
.add("ffmpeg") | |||
.add("-rtsp_transport", "tcp").add("-i", playUrl) | |||
.add("-vcodec", "copy") | |||
.add("-acodec", "copy") | |||
/*.add("-acodec", "copy")*/ | |||
.add("-f", "flv") | |||
.add("-b:v", "2M") | |||
.add("-maxrate", "2M") | |||
@@ -98,10 +99,10 @@ public class RtmpLiveService { | |||
.add("-y").add(cmdParam.getPushUrl())); | |||
Thread.sleep(3000); | |||
String taskId2 = manager.start("test2", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", playUrl) | |||
.add("-rtsp_transport", "tcp") | |||
.add("ffmpeg") | |||
.add("-rtsp_transport", "tcp").add("-i", playUrl) | |||
.add("-vcodec", "copy") | |||
.add("-acodec", "copy") | |||
/* .add("-acodec", "copy")*/ | |||
.add("-f", "flv") | |||
.add("-b:v", "2M") | |||
.add("-maxrate", "2M") | |||
@@ -135,8 +136,8 @@ public class RtmpLiveService { | |||
//单进程 多路 | |||
String reTopic = cmdParam.getMqttTopic().replace("live", "result"); | |||
String taskId = manager.start("test4", CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", playUrl) | |||
.add("-rtsp_transport", "tcp") | |||
.add("ffmpeg") | |||
.add("-rtsp_transport", "tcp").add("-i", playUrl) | |||
.add("-vcodec", "copy") | |||
.add("-acodec", "copy") | |||
.add("-b:v", "2M") | |||
@@ -218,16 +219,17 @@ public class RtmpLiveService { | |||
log.info("获取播流地址:{}"); | |||
//CommandManager manager = new CommandManagerImpl(); | |||
String taskId = manager.start(code, CommandBuidlerFactory.createBuidler() | |||
.add("ffmpeg").add("-i", playUrl) | |||
.add("-rtsp_transport", "tcp") | |||
.add("ffmpeg").add("-rtsp_transport", "tcp") | |||
.add("-i", playUrl) | |||
.add("-vcodec", "copy") | |||
.add("-acodec", "copy") | |||
/*.add("-acodec", "copy")*/ | |||
.add("-f", "flv") | |||
.add("-b:v", "2M") | |||
.add("-maxrate", "2M") | |||
.add("-bufsize", "1M") | |||
.add("-v", "trace ") | |||
.add("-y").add(pushUrl)); | |||
/* .add("-b:v", "1000") | |||
.add("-maxrate", "3000") | |||
.add("-bufsize", "6000") | |||
.add("-rtbufsize ", "6000") | |||
.add("-max_delay", "4000")*/ | |||
.add("-an").add(pushUrl)); | |||
cmdParam.getMqttTopic(); | |||
String reTopic = cmdParam.getMqttTopic().replace("live", "result"); | |||