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