Commit 2af5cf496c811fd302564c7edb29d4e5f6cf31e2
1 parent
a209ba77
修复 拉流代理的ffmpeg模式
Showing
8 changed files
with
69 additions
and
8 deletions
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| @@ -176,13 +176,17 @@ public class ZLMRESTfulUtils { | @@ -176,13 +176,17 @@ public class ZLMRESTfulUtils { | ||
| 176 | return sendPost("getRtpInfo",param, null); | 176 | return sendPost("getRtpInfo",param, null); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | - public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms){ | 179 | + public JSONObject addFFmpegSource(String src_url, String dst_url, String timeout_ms, |
| 180 | + boolean enable_hls, boolean enable_mp4, String ffmpeg_cmd_key){ | ||
| 180 | logger.info(src_url); | 181 | logger.info(src_url); |
| 181 | logger.info(dst_url); | 182 | logger.info(dst_url); |
| 182 | Map<String, Object> param = new HashMap<>(); | 183 | Map<String, Object> param = new HashMap<>(); |
| 183 | param.put("src_url", src_url); | 184 | param.put("src_url", src_url); |
| 184 | param.put("dst_url", dst_url); | 185 | param.put("dst_url", dst_url); |
| 185 | param.put("timeout_ms", timeout_ms); | 186 | param.put("timeout_ms", timeout_ms); |
| 187 | + param.put("enable_hls", enable_hls); | ||
| 188 | + param.put("enable_mp4", enable_mp4); | ||
| 189 | + param.put("ffmpeg_cmd_key", ffmpeg_cmd_key); | ||
| 186 | return sendPost("addFFmpegSource",param, null); | 190 | return sendPost("addFFmpegSource",param, null); |
| 187 | } | 191 | } |
| 188 | 192 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
| @@ -115,7 +115,7 @@ public class ZLMRunner implements CommandLineRunner { | @@ -115,7 +115,7 @@ public class ZLMRunner implements CommandLineRunner { | ||
| 115 | } | 115 | } |
| 116 | Map<String, Object> param = new HashMap<>(); | 116 | Map<String, Object> param = new HashMap<>(); |
| 117 | param.put("api.secret",mediaConfig.getSecret()); // -profile:v Baseline | 117 | param.put("api.secret",mediaConfig.getSecret()); // -profile:v Baseline |
| 118 | -// 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"); | 118 | + 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"); |
| 119 | param.put("hook.enable","1"); | 119 | param.put("hook.enable","1"); |
| 120 | param.put("hook.on_flow_report",""); | 120 | param.put("hook.on_flow_report",""); |
| 121 | param.put("hook.on_play",String.format("%s/on_play", hookPrex)); | 121 | param.put("hook.on_play",String.format("%s/on_play", hookPrex)); |
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
| @@ -56,4 +56,10 @@ public interface IStreamProxyService { | @@ -56,4 +56,10 @@ public interface IStreamProxyService { | ||
| 56 | * @return | 56 | * @return |
| 57 | */ | 57 | */ |
| 58 | boolean stop(String app, String stream); | 58 | boolean stop(String app, String stream); |
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 获取ffmpeg.cmd模板 | ||
| 62 | + * @return | ||
| 63 | + */ | ||
| 64 | + JSONObject getFFmpegCMDs(); | ||
| 59 | } | 65 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
| @@ -104,7 +104,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -104,7 +104,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 104 | param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type()); | 104 | param.isEnable_hls(), param.isEnable_mp4(), param.getRtp_type()); |
| 105 | }else if ("ffmpeg".equals(param.getType())) { | 105 | }else if ("ffmpeg".equals(param.getType())) { |
| 106 | result = zlmresTfulUtils.addFFmpegSource(param.getSrc_url(), param.getDst_url(), | 106 | result = zlmresTfulUtils.addFFmpegSource(param.getSrc_url(), param.getDst_url(), |
| 107 | - param.getTimeout_ms() + ""); | 107 | + param.getTimeout_ms() + "", param.isEnable_hls(), param.isEnable_mp4(), |
| 108 | + param.getFfmpeg_cmd_key()); | ||
| 108 | } | 109 | } |
| 109 | return result; | 110 | return result; |
| 110 | } | 111 | } |
| @@ -165,4 +166,22 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | @@ -165,4 +166,22 @@ public class StreamProxyServiceImpl implements IStreamProxyService { | ||
| 165 | } | 166 | } |
| 166 | return result; | 167 | return result; |
| 167 | } | 168 | } |
| 169 | + | ||
| 170 | + @Override | ||
| 171 | + public JSONObject getFFmpegCMDs() { | ||
| 172 | + JSONObject result = new JSONObject(); | ||
| 173 | + JSONObject mediaServerConfigResuly = zlmresTfulUtils.getMediaServerConfig(); | ||
| 174 | + if (mediaServerConfigResuly != null && mediaServerConfigResuly.getInteger("code") == 0 | ||
| 175 | + && mediaServerConfigResuly.getJSONArray("data").size() > 0){ | ||
| 176 | + JSONObject mediaServerConfig = mediaServerConfigResuly.getJSONArray("data").getJSONObject(0); | ||
| 177 | + | ||
| 178 | + for (String key : mediaServerConfig.keySet()) { | ||
| 179 | + if (key.startsWith("ffmpeg.cmd")){ | ||
| 180 | + result.put(key, mediaServerConfig.getString(key)); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + return result; | ||
| 186 | + } | ||
| 168 | } | 187 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| @@ -168,7 +168,7 @@ public class PlayController { | @@ -168,7 +168,7 @@ public class PlayController { | ||
| 168 | String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), | 168 | String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), |
| 169 | streamId ); | 169 | streamId ); |
| 170 | String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); | 170 | String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); |
| 171 | - JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000"); | 171 | + JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(srcUrl, dstUrl, "1000000", true, false, null); |
| 172 | logger.info(jsonObject.toJSONString()); | 172 | logger.info(jsonObject.toJSONString()); |
| 173 | JSONObject result = new JSONObject(); | 173 | JSONObject result = new JSONObject(); |
| 174 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { | 174 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { |
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
| @@ -66,6 +66,19 @@ public class StreamProxyController { | @@ -66,6 +66,19 @@ public class StreamProxyController { | ||
| 66 | return result; | 66 | return result; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | + @ApiOperation("获取ffmpeg.cmd模板") | ||
| 70 | + @GetMapping(value = "/ffmpeg_cmd/list") | ||
| 71 | + @ResponseBody | ||
| 72 | + public WVPResult getFFmpegCMDs(){ | ||
| 73 | + logger.debug("获取ffmpeg.cmd模板:" ); | ||
| 74 | + JSONObject data = streamProxyService.getFFmpegCMDs(); | ||
| 75 | + WVPResult<JSONObject> result = new WVPResult<>(); | ||
| 76 | + result.setCode(0); | ||
| 77 | + result.setMsg("success"); | ||
| 78 | + result.setData(data); | ||
| 79 | + return result; | ||
| 80 | + } | ||
| 81 | + | ||
| 69 | @ApiOperation("移除代理") | 82 | @ApiOperation("移除代理") |
| 70 | @ApiImplicitParams({ | 83 | @ApiImplicitParams({ |
| 71 | @ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class), | 84 | @ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class), |
web_src/src/components/CloudRecord.vue
| @@ -14,8 +14,6 @@ | @@ -14,8 +14,6 @@ | ||
| 14 | </div> | 14 | </div> |
| 15 | <div v-if="!recordDetail"> | 15 | <div v-if="!recordDetail"> |
| 16 | <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> | 16 | <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> |
| 17 | - | ||
| 18 | - | ||
| 19 | 节点选择: <el-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;" v-model="mediaServer" placeholder="请选择" default-first-option> | 17 | 节点选择: <el-select size="mini" @change="chooseMediaChange" style="width: 16rem; margin-right: 1rem;" v-model="mediaServer" placeholder="请选择" default-first-option> |
| 20 | <el-option | 18 | <el-option |
| 21 | v-for="item in mediaServerList" | 19 | v-for="item in mediaServerList" |
web_src/src/components/dialog/StreamProxyEdit.vue
| @@ -36,11 +36,23 @@ | @@ -36,11 +36,23 @@ | ||
| 36 | <el-form-item label="拉流地址" prop="src_url" v-if="proxyParam.type=='ffmpeg'"> | 36 | <el-form-item label="拉流地址" prop="src_url" v-if="proxyParam.type=='ffmpeg'"> |
| 37 | <el-input v-model="proxyParam.src_url" clearable></el-input> | 37 | <el-input v-model="proxyParam.src_url" clearable></el-input> |
| 38 | </el-form-item> | 38 | </el-form-item> |
| 39 | - <el-form-item label="超时时间" prop="timeout_ms" v-if="proxyParam.type=='ffmpeg'"> | 39 | + <el-form-item label="超时时间:秒" prop="timeout_ms" v-if="proxyParam.type=='ffmpeg'"> |
| 40 | <el-input v-model="proxyParam.timeout_ms" clearable></el-input> | 40 | <el-input v-model="proxyParam.timeout_ms" clearable></el-input> |
| 41 | </el-form-item> | 41 | </el-form-item> |
| 42 | <el-form-item label="FFmpeg命令模板" prop="ffmpeg_cmd_key" v-if="proxyParam.type=='ffmpeg'"> | 42 | <el-form-item label="FFmpeg命令模板" prop="ffmpeg_cmd_key" v-if="proxyParam.type=='ffmpeg'"> |
| 43 | - <el-input v-model="proxyParam.ffmpeg_cmd_key" clearable></el-input> | 43 | +<!-- <el-input v-model="proxyParam.ffmpeg_cmd_key" clearable></el-input>--> |
| 44 | + <el-select | ||
| 45 | + v-model="proxyParam.ffmpeg_cmd_key" | ||
| 46 | + style="width: 100%" | ||
| 47 | + placeholder="请选择FFmpeg命令模板" | ||
| 48 | + > | ||
| 49 | + <el-option | ||
| 50 | + v-for="item in Object.keys(ffmpegCmdList)" | ||
| 51 | + :key="item" | ||
| 52 | + :label="ffmpegCmdList[item]" | ||
| 53 | + :value="item"> | ||
| 54 | + </el-option> | ||
| 55 | + </el-select> | ||
| 44 | </el-form-item> | 56 | </el-form-item> |
| 45 | <el-form-item label="国标编码" prop="gbId"> | 57 | <el-form-item label="国标编码" prop="gbId"> |
| 46 | <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input> | 58 | <el-input v-model="proxyParam.gbId" placeholder="设置国标编码可推送到国标" clearable></el-input> |
| @@ -159,6 +171,7 @@ export default { | @@ -159,6 +171,7 @@ export default { | ||
| 159 | enable_mp4: false, | 171 | enable_mp4: false, |
| 160 | platformGbId: null, | 172 | platformGbId: null, |
| 161 | }, | 173 | }, |
| 174 | + ffmpegCmdList:{}, | ||
| 162 | 175 | ||
| 163 | rules: { | 176 | rules: { |
| 164 | name: [{ required: true, message: "请输入名称", trigger: "blur" }], | 177 | name: [{ required: true, message: "请输入名称", trigger: "blur" }], |
| @@ -189,6 +202,14 @@ export default { | @@ -189,6 +202,14 @@ export default { | ||
| 189 | }).catch(function (error) { | 202 | }).catch(function (error) { |
| 190 | console.log(error); | 203 | console.log(error); |
| 191 | }); | 204 | }); |
| 205 | + this.$axios({ | ||
| 206 | + method: 'get', | ||
| 207 | + url:`/api/proxy/ffmpeg_cmd/list` | ||
| 208 | + }).then(function (res) { | ||
| 209 | + that.ffmpegCmdList = res.data.data; | ||
| 210 | + }).catch(function (error) { | ||
| 211 | + console.log(error); | ||
| 212 | + }); | ||
| 192 | }, | 213 | }, |
| 193 | onSubmit: function () { | 214 | onSubmit: function () { |
| 194 | console.log("onSubmit"); | 215 | console.log("onSubmit"); |