修复 拉流代理的ffmpeg模式
This commit is contained in:
parent
a209ba77ea
commit
2af5cf496c
@ -176,13 +176,17 @@ public class ZLMRESTfulUtils {
|
|||||||
return sendPost("getRtpInfo",param, null);
|
return sendPost("getRtpInfo",param, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){
|
public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms,
|
||||||
|
boolean enable_hls, boolean enable_mp4, String ffmpeg_cmd_key){
|
||||||
logger.info(src_url);
|
logger.info(src_url);
|
||||||
logger.info(dst_url);
|
logger.info(dst_url);
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("src_url", src_url);
|
param.put("src_url", src_url);
|
||||||
param.put("dst_url", dst_url);
|
param.put("dst_url", dst_url);
|
||||||
param.put("timeout_ms", timeout_ms);
|
param.put("timeout_ms", timeout_ms);
|
||||||
|
param.put("enable_hls", enable_hls);
|
||||||
|
param.put("enable_mp4", enable_mp4);
|
||||||
|
param.put("ffmpeg_cmd_key", ffmpeg_cmd_key);
|
||||||
return sendPost("addFFmpegSource",param, null);
|
return sendPost("addFFmpegSource",param, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public class ZLMRunner implements CommandLineRunner {
|
|||||||
}
|
}
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>();
|
||||||
param.put("api.secret",mediaConfig.getSecret()); // -profile:v Baseline
|
param.put("api.secret",mediaConfig.getSecret()); // -profile:v Baseline
|
||||||
// param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s");
|
param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s");
|
||||||
param.put("hook.enable","1");
|
param.put("hook.enable","1");
|
||||||
param.put("hook.on_flow_report","");
|
param.put("hook.on_flow_report","");
|
||||||
param.put("hook.on_play",String.format("%s/on_play", hookPrex));
|
param.put("hook.on_play",String.format("%s/on_play", hookPrex));
|
||||||
|
@ -56,4 +56,10 @@ public interface IStreamProxyService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean stop(String app, String stream);
|
boolean stop(String app, String stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取ffmpeg.cmd模板
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JSONObject getFFmpegCMDs();
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type());
|
param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type());
|
||||||
}else if ("ffmpeg".equals(param.getType())) {
|
}else if ("ffmpeg".equals(param.getType())) {
|
||||||
result = zlmresTfulUtils.addFFmpegSource(param.getSrc_url(), param.getDst_url(),
|
result = zlmresTfulUtils.addFFmpegSource(param.getSrc_url(), param.getDst_url(),
|
||||||
param.getTimeout_ms() + "");
|
param.getTimeout_ms() + "", param.isEnable_hls(), param.isEnable_mp4(),
|
||||||
|
param.getFfmpeg_cmd_key());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -165,4 +166,22 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getFFmpegCMDs() {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
JSONObject mediaServerConfigResuly = zlmresTfulUtils.getMediaServerConfig();
|
||||||
|
if (mediaServerConfigResuly != null && mediaServerConfigResuly.getInteger("code") == 0
|
||||||
|
&& mediaServerConfigResuly.getJSONArray("data").size() > 0){
|
||||||
|
JSONObject mediaServerConfig = mediaServerConfigResuly.getJSONArray("data").getJSONObject(0);
|
||||||
|
|
||||||
|
for (String key : mediaServerConfig.keySet()) {
|
||||||
|
if (key.startsWith("ffmpeg.cmd")){
|
||||||
|
result.put(key, mediaServerConfig.getString(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ public class PlayController {
|
|||||||
String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(),
|
String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(),
|
||||||
streamId );
|
streamId );
|
||||||
String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId);
|
String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId);
|
||||||
JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000");
|
JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000", true, false, null);
|
||||||
logger.info(jsonObject.toJSONString());
|
logger.info(jsonObject.toJSONString());
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
|
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
|
||||||
|
@ -66,6 +66,19 @@ public class StreamProxyController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("获取ffmpeg.cmd模板")
|
||||||
|
@GetMapping(value = "/ffmpeg_cmd/list")
|
||||||
|
@ResponseBody
|
||||||
|
public WVPResult getFFmpegCMDs(){
|
||||||
|
logger.debug("获取ffmpeg.cmd模板:" );
|
||||||
|
JSONObject data = streamProxyService.getFFmpegCMDs();
|
||||||
|
WVPResult<JSONObject> result = new WVPResult<>();
|
||||||
|
result.setCode(0);
|
||||||
|
result.setMsg("success");
|
||||||
|
result.setData(data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("移除代理")
|
@ApiOperation("移除代理")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
|
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="!recordDetail">
|
<div v-if="!recordDetail">
|
||||||
<div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
|
<div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;">
|
||||||
|
|
||||||
|
|
||||||
节点选择: <el-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;" v-model="mediaServer" placeholder="请选择" default-first-option>
|
节点选择: <el-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;" v-model="mediaServer" placeholder="请选择" default-first-option>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in mediaServerList"
|
v-for="item in mediaServerList"
|
||||||
|
@ -36,11 +36,23 @@
|
|||||||
<el-form-item label="拉流地址" prop="src_url" v-if="proxyParam.type=='ffmpeg'">
|
<el-form-item label="拉流地址" prop="src_url" v-if="proxyParam.type=='ffmpeg'">
|
||||||
<el-input v-model="proxyParam.src_url" clearable></el-input>
|
<el-input v-model="proxyParam.src_url" clearable></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="超时时间" prop="timeout_ms" v-if="proxyParam.type=='ffmpeg'">
|
<el-form-item label="超时时间:秒" prop="timeout_ms" v-if="proxyParam.type=='ffmpeg'">
|
||||||
<el-input v-model="proxyParam.timeout_ms" clearable></el-input>
|
<el-input v-model="proxyParam.timeout_ms" clearable></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="FFmpeg命令模板" prop="ffmpeg_cmd_key" v-if="proxyParam.type=='ffmpeg'">
|
<el-form-item label="FFmpeg命令模板" prop="ffmpeg_cmd_key" v-if="proxyParam.type=='ffmpeg'">
|
||||||
<el-input v-model="proxyParam.ffmpeg_cmd_key" clearable></el-input>
|
<!-- <el-input v-model="proxyParam.ffmpeg_cmd_key" clearable></el-input>-->
|
||||||
|
<el-select
|
||||||
|
v-model="proxyParam.ffmpeg_cmd_key"
|
||||||
|
style="width: 100%"
|
||||||
|
placeholder="请选择FFmpeg命令模板"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in Object.keys(ffmpegCmdList)"
|
||||||
|
:key="item"
|
||||||
|
:label="ffmpegCmdList[item]"
|
||||||
|
:value="item">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="国标编码" prop="gbId">
|
<el-form-item label="国标编码" prop="gbId">
|
||||||
<el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input>
|
<el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input>
|
||||||
@ -159,6 +171,7 @@ export default {
|
|||||||
enable_mp4: false,
|
enable_mp4: false,
|
||||||
platformGbId: null,
|
platformGbId: null,
|
||||||
},
|
},
|
||||||
|
ffmpegCmdList:{},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
|
||||||
@ -189,6 +202,14 @@ export default {
|
|||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
|
this.$axios({
|
||||||
|
method: 'get',
|
||||||
|
url:`/api/proxy/ffmpeg_cmd/list`
|
||||||
|
}).then(function (res) {
|
||||||
|
that.ffmpegCmdList = res.data.data;
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onSubmit: function () {
|
onSubmit: function () {
|
||||||
console.log("onSubmit");
|
console.log("onSubmit");
|
||||||
|
Loading…
Reference in New Issue
Block a user