|
@@ -27,13 +27,20 @@ public class TaskController {
|
|
|
@GetMapping("/play")
|
|
|
public String play(@RequestParam(value = "url", required = true) String url,
|
|
|
@RequestParam(value = "name", required = true) String name,
|
|
|
- @RequestParam(value = "flags", required = true) String flags) throws InterruptedException {
|
|
|
+ @RequestParam(value = "dt", required = false) Integer delayTime,
|
|
|
+ @RequestParam(value = "targetUrl", required = true) String targetUrl) throws InterruptedException {
|
|
|
+ System.out.println("#接收参数 url=" + url);
|
|
|
+ System.out.println("#接收参数 name=" + name);
|
|
|
+ System.out.println("#接收参数 delayTime=" + delayTime);
|
|
|
+ if (delayTime == null) {
|
|
|
+ delayTime = Integer.valueOf(3000);
|
|
|
+ }
|
|
|
+ System.out.println("#接收参数 delayTime2=" + delayTime);
|
|
|
+
|
|
|
url = url.replace("rtsp://", "");
|
|
|
String mediaName = getMedia(url);
|
|
|
- //TEST
|
|
|
- name = mediaName;
|
|
|
- //{启动}
|
|
|
- String media = manager.start(name, CommandBuidlerFactory.createBuidler()
|
|
|
+
|
|
|
+ String media = this.manager.start(name, CommandBuidlerFactory.createBuidler()
|
|
|
.add("ffmpeg")
|
|
|
.add("-f", "rtsp")
|
|
|
.add("-rtsp_transport", "tcp")
|
|
@@ -41,23 +48,55 @@ public class TaskController {
|
|
|
.add("-c", "copy")
|
|
|
.add("-f", "hls")
|
|
|
.add("-hls_time", "2.0")
|
|
|
-// .add("-hls_list_size", "1")
|
|
|
-// .add("-hls_wrap", "15")
|
|
|
- .add("-hls_list_size", "2")
|
|
|
- .add(" -hls_flags", flags)
|
|
|
-// .add("/usr/local/nginx/html/hls/" + mediaName + ".m3u8"),url,mediaName);
|
|
|
- .add("D:\\nginx-1.20.2\\html\\hls\\"+mediaName+".m3u8"),url,mediaName);
|
|
|
+ .add("-hls_list_size", "1")
|
|
|
+ .add("-hls_wrap", "15")
|
|
|
+ .add("/usr/local/nginx/html/hls/" + mediaName + ".m3u8"), url, mediaName);
|
|
|
+
|
|
|
+ Thread.sleep(delayTime.intValue());
|
|
|
|
|
|
- Thread.sleep(10000);
|
|
|
- System.out.println("C1 media="+mediaName);
|
|
|
+ System.out.println("C1 media=" + mediaName);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("url", "/hls/" + mediaName + ".m3u8");
|
|
|
+ jsonObject.put("url", targetUrl + "/hls/" + mediaName + ".m3u8");
|
|
|
jsonObject.put("name", name);
|
|
|
- jsonObject.put("code", 8200);
|
|
|
+ jsonObject.put("code", Integer.valueOf(8200));
|
|
|
jsonObject.put("message", "请求成功。");
|
|
|
return jsonObject.toJSONString();
|
|
|
}
|
|
|
|
|
|
+// @GetMapping("/play")
|
|
|
+// public String play(@RequestParam(value = "url", required = true) String url,
|
|
|
+// @RequestParam(value = "name", required = true) String name,
|
|
|
+// @RequestParam(value = "flags", required = true) String flags) throws InterruptedException {
|
|
|
+// url = url.replace("rtsp://", "");
|
|
|
+// String mediaName = getMedia(url);
|
|
|
+// //TEST
|
|
|
+// name = mediaName;
|
|
|
+// //{启动}
|
|
|
+// String media = manager.start(name, CommandBuidlerFactory.createBuidler()
|
|
|
+// .add("ffmpeg")
|
|
|
+// .add("-f", "rtsp")
|
|
|
+// .add("-rtsp_transport", "tcp")
|
|
|
+// .add("-i", "rtsp://" + url)
|
|
|
+// .add("-c", "copy")
|
|
|
+// .add("-f", "hls")
|
|
|
+// .add("-hls_time", "2.0")
|
|
|
+//// .add("-hls_list_size", "1")
|
|
|
+// .add("-hls_wrap", "15")
|
|
|
+// .add("-hls_list_size", "2")
|
|
|
+//// .add(" -hls_flags", flags)
|
|
|
+// .add("/usr/local/nginx/html/hls/" + mediaName + ".m3u8"),url,mediaName);
|
|
|
+//// .add("D:\\nginx-1.20.2\\html\\hls\\"+mediaName+".m3u8"),url,mediaName);
|
|
|
+//
|
|
|
+// Thread.sleep(10000);
|
|
|
+// System.out.println("C1 media="+mediaName);
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("url", "/hls/" + mediaName + ".m3u8");
|
|
|
+// jsonObject.put("name", name);
|
|
|
+// jsonObject.put("code", 8200);
|
|
|
+// jsonObject.put("message", "请求成功。");
|
|
|
+// return jsonObject.toJSONString();
|
|
|
+// }
|
|
|
+
|
|
|
// @PostMapping("/start2")
|
|
|
// public String start2(@RequestBody @Validated StartParam param) {
|
|
|
// String name;
|