ffmpeg工具固定通道版本
This commit is contained in:
parent
e8fa581588
commit
82605691e6
|
|
@ -1,10 +1,13 @@
|
||||||
#芢霜華硊ㄗegㄩ陝爵堁華硊ㄘ
|
#芢霜華硊ㄗegㄩ陝爵堁華硊ㄘ
|
||||||
pushUrl=rtmp://192.168.10.101:19350/rlive/stream_12?sign=LeL5Wchx
|
pushUrl=rtmp://192.168.10.101:19350/rlive/stream_12?sign=LeL5Wchx
|
||||||
|
#多路推流
|
||||||
|
pushUrlMap=tee "[f=flv]rtmp://192.168.10.101:19350/rlive/stream_12?sign=LeL5Wchx | [f=flv]rtmp://192.168.10.101:19350/rlive/stream_17?sign=64FIaU8X"
|
||||||
pushUrl2=rtmp://192.168.10.101:19350/rlive/stream_17?sign=64FIaU8X
|
pushUrl2=rtmp://192.168.10.101:19350/rlive/stream_17?sign=64FIaU8X
|
||||||
#嶺霜華硊ㄗegㄩ裂組嶺霜腔華硊ㄘ
|
#嶺霜華硊ㄗegㄩ裂組嶺霜腔華硊ㄘ
|
||||||
playUrl=http://192.168.10.101:18000/flv/live/34020000001110000001_34020000001320000099_0200000099.flv
|
playUrl=http://192.168.10.101:18000/flv/live/34020000001110000001_34020000001320000099_0200000099.flv
|
||||||
#미땍繫돛 1 삿혤繫돛 2
|
#固定通道 1 获取通道 2 多线程双路 3 单线程多路 4
|
||||||
type=1
|
type=4
|
||||||
|
|
||||||
mqttUrl=tcp://106.15.120.154
|
mqttUrl=tcp://106.15.120.154
|
||||||
mqttTopic=/v1/123987/rtmp/live
|
mqttTopic=/v1/123987/rtmp/live
|
||||||
|
time=60000
|
||||||
|
|
@ -2,12 +2,31 @@ package com.github.bluesbruce.spring.config;
|
||||||
|
|
||||||
public class CmdParam {
|
public class CmdParam {
|
||||||
private String pushUrl;//
|
private String pushUrl;//
|
||||||
|
private String pushUrlMap;//
|
||||||
private String pushUrl2;//
|
private String pushUrl2;//
|
||||||
private String playUrl;//
|
private String playUrl;//
|
||||||
private int type;//1 固定通道 2 通道服务
|
private int type;//1 固定通道 2 通道服务
|
||||||
String mqttUrl;
|
String mqttUrl;
|
||||||
|
int time;
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTime(int time) {
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
private String mqttTopic;
|
private String mqttTopic;
|
||||||
|
|
||||||
|
public String getPushUrlMap() {
|
||||||
|
return pushUrlMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPushUrlMap(String pushUrlMap) {
|
||||||
|
this.pushUrlMap = pushUrlMap;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPushUrl2() {
|
public String getPushUrl2() {
|
||||||
return pushUrl2;
|
return pushUrl2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class MqttProviderConfig {
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init(){
|
public void init(){
|
||||||
//connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,7 +44,7 @@ public class MqttProviderConfig {
|
||||||
//设置为true表示每次连接服务器都是以新的身份
|
//设置为true表示每次连接服务器都是以新的身份
|
||||||
options.setCleanSession(true);
|
options.setCleanSession(true);
|
||||||
//设置连接用户名
|
//设置连接用户名
|
||||||
options.setUserName("");
|
options.setUserName("ffmpge");
|
||||||
//设置连接密码
|
//设置连接密码
|
||||||
options.setPassword("".toCharArray());
|
options.setPassword("".toCharArray());
|
||||||
//设置超时时间,单位为秒
|
//设置超时时间,单位为秒
|
||||||
|
|
|
||||||
|
|
@ -22,25 +22,37 @@ 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所在的完整路径
|
||||||
//manager.start("tomcat", "ffmpeg -i http://192.168.10.101:18000/flv/live/34020000001110000002_34020000001320000071_0200000071.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.10.101:19350/rlive/stream_9?sign=f8a15b6n",false);
|
//manager.start("tomcat", "ffmpeg -i http://192.168.10.101:18000/flv/live/34020000001110000002_34020000001320000071_0200000071.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.10.101:19350/rlive/stream_9?sign=f8a15b6n",false);
|
||||||
//manager.start("tomcat", "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_9?sign=f8a15b6n",false);
|
//manager.start("tomcat", "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_9?sign=f8a15b6n",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);
|
//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("test1", CommandBuidlerFactory.createBuidler()
|
if (cmdParam.getType()==1) {
|
||||||
.add("ffmpeg").add("-i",cmdParam.getPlayUrl())
|
manager.start("test0", CommandBuidlerFactory.createBuidler()
|
||||||
.add("-rtsp_transport","tcp")
|
.add("ffmpeg").add("-i", cmdParam.getPlayUrl())
|
||||||
.add("-vcodec","copy")
|
.add("-rtsp_transport","tcp")
|
||||||
.add("-acodec","copy")
|
.add("-vcodec","copy")
|
||||||
.add("-f","flv")
|
.add("-acodec","copy")
|
||||||
.add("-b:v", "2M")
|
.add("-f","flv")
|
||||||
.add("-maxrate", "2M")
|
.add("-b:v", "2M")
|
||||||
.add("-bufsize", "1M")
|
.add("-maxrate", "2M")
|
||||||
.add("-y").add(cmdParam.getPushUrl()));
|
.add("-bufsize", "1M")
|
||||||
Thread.sleep(10000);
|
.add("-y").add(cmdParam.getPushUrl()));
|
||||||
manager.start("test2", CommandBuidlerFactory.createBuidler()
|
}else if (cmdParam.getType()==3) {
|
||||||
|
manager.start("test1", CommandBuidlerFactory.createBuidler()
|
||||||
|
.add("ffmpeg").add("-i", cmdParam.getPlayUrl())
|
||||||
|
.add("-rtsp_transport","tcp")
|
||||||
|
.add("-vcodec","copy")
|
||||||
|
.add("-acodec","copy")
|
||||||
|
.add("-f","flv")
|
||||||
|
.add("-b:v", "2M")
|
||||||
|
.add("-maxrate", "2M")
|
||||||
|
.add("-bufsize", "1M")
|
||||||
|
.add("-y").add(cmdParam.getPushUrl()));
|
||||||
|
Thread.sleep(5000);
|
||||||
|
manager.start("test2", CommandBuidlerFactory.createBuidler()
|
||||||
.add("ffmpeg").add("-i",cmdParam.getPlayUrl())
|
.add("ffmpeg").add("-i",cmdParam.getPlayUrl())
|
||||||
.add("-rtsp_transport","tcp")
|
.add("-rtsp_transport","tcp")
|
||||||
.add("-vcodec","copy")
|
.add("-vcodec","copy")
|
||||||
|
|
@ -50,9 +62,23 @@ public class FFrtmpServer implements ApplicationRunner {
|
||||||
.add("-maxrate", "2M")
|
.add("-maxrate", "2M")
|
||||||
.add("-bufsize", "1M")
|
.add("-bufsize", "1M")
|
||||||
.add("-y").add(cmdParam.getPushUrl2()));
|
.add("-y").add(cmdParam.getPushUrl2()));
|
||||||
Thread.sleep(300000);
|
}else if (cmdParam.getType()==4){
|
||||||
|
//单进程 多路
|
||||||
|
manager.start("test4", CommandBuidlerFactory.createBuidler()
|
||||||
|
.add("ffmpeg").add("-i", cmdParam.getPlayUrl())
|
||||||
|
.add("-rtsp_transport", "tcp")
|
||||||
|
.add("-vcodec", "copy")
|
||||||
|
.add("-acodec", "copy")
|
||||||
|
.add("-b:v", "2M")
|
||||||
|
.add("-maxrate", "2M")
|
||||||
|
.add("-bufsize", "1M")
|
||||||
|
//多路推流测试
|
||||||
|
.add("-map", "0")
|
||||||
|
.add("-f").add(cmdParam.getPushUrlMap()));
|
||||||
|
}
|
||||||
|
Thread.sleep(cmdParam.getTime());
|
||||||
// 停止全部任务
|
// 停止全部任务
|
||||||
manager.stopAll();
|
manager.stopAll();*/
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("",e);
|
log.error("",e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class RtmpLiveService {
|
||||||
log.info(infoList.toString());
|
log.info(infoList.toString());
|
||||||
if (infoList.size()>0){
|
if (infoList.size()>0){
|
||||||
jsonObject.put("code", -1);
|
jsonObject.put("code", -1);
|
||||||
jsonObject.put("msg", "推流服务已启动"); //推流失败
|
jsonObject.put("msg", "推流服务已启动,请勿重复启动"); //推流失败
|
||||||
mqttProviderConfig.publish(2,false,reTopic,jsonObject.toJSONString());
|
mqttProviderConfig.publish(2,false,reTopic,jsonObject.toJSONString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +52,7 @@ public class RtmpLiveService {
|
||||||
//TODO 获取通道服务推拉流地址
|
//TODO 获取通道服务推拉流地址
|
||||||
JSONObject object = getChenl();
|
JSONObject object = getChenl();
|
||||||
if (!ObjectUtils.isEmpty(object)){
|
if (!ObjectUtils.isEmpty(object)){
|
||||||
|
code = object.get("code").toString();
|
||||||
object.put("code", 0);
|
object.put("code", 0);
|
||||||
object.put("msg", "获取通道成功");
|
object.put("msg", "获取通道成功");
|
||||||
mqttProviderConfig.publish(2,false,reTopic,object.toJSONString());
|
mqttProviderConfig.publish(2,false,reTopic,object.toJSONString());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue