From 7a3fdf9f4cbfa17a448202d657a2dbf0e711aded Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 31 八月 2023 10:47:30 +0800
Subject: [PATCH] 流媒体优化
---
ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java
similarity index 96%
rename from ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
rename to ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java
index 6647b49..c7cdcc4 100644
--- a/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaService.java
+++ b/ard-work/src/main/java/com/ruoyi/media/service/impl/MediaServiceImpl.java
@@ -2,7 +2,6 @@
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.media.domain.*;
import com.ruoyi.media.mapper.VtduMapper;
import com.ruoyi.media.service.IMediaService;
@@ -34,7 +33,7 @@
**/
@Service
@Slf4j(topic = "cmd")
-public class MediaService implements IMediaService {
+public class MediaServiceImpl implements IMediaService {
@Resource
VtduMapper vtduMapper;
@Resource
@@ -103,7 +102,7 @@
public String addPath(String name, String rtspPath, String mode, String isCode) {
String rtspUrl = "rtsp://" + mediamtxHost + ":7554/" + name;
Conf mediaInfo = new Conf();
- String rootPath = System.getProperty("user.dir").replaceAll("\\\\", "/");
+ String rootPath = System.getProperty("user.dir").replaceAll("\\\\", "/")+ "/lib/mediamtx/";
//-vcodec libx264 //鎸囧畾瑙嗛缂栫爜鍣ㄤ负 libx264锛屼娇鐢� H.264 缂栫爜鏍煎紡杩涜瑙嗛鍘嬬缉
//-preset ultrafast //--preset鐨勫弬鏁颁富瑕佽皟鑺傜紪鐮侀�熷害鍜岃川閲忕殑骞宠 锛屾湁ultrafast锛堣浆鐮侀�熷害鏈�蹇紝瑙嗛寰�寰�涔熸渶妯$硦锛夈�乻uperfast銆乿eryfast銆乫aster銆乫ast銆乵edium銆乻low銆乻lower銆乿eryslow銆乸lacebo杩�10涓�夐」锛屼粠蹇埌鎱�
//-r 25 //璁剧疆杈撳嚭瑙嗛鐨勫抚鐜囦负 25 甯�/绉�
@@ -117,9 +116,9 @@
//GPU纭В鐮佺紪鐮� -hwaccel cuvid -c:v h264_cuvid 浣跨敤cuda瑙g爜 -c:v h264_nvenc 浣跨敤cuda缂栫爜
//String cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport udp -i " + rtspPath + " -c:v h264_nvenc -r 25 -threads 4 -b:v 2048k -bf 0 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
if (isCode.equals("1")) {
- String cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -rtsp_transport tcp -i " + rtspPath + " -vcodec libx264 -preset:v ultrafast -r 25 -threads 6 -b:v 1024k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
+ String cmd = "ffmpeg -rtsp_transport tcp -i " + rtspPath + " -vcodec libx264 -preset:v ultrafast -r 25 -threads 6 -b:v 1024k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
if (!softwareDecoding) {
- cmd = rootPath + "/lib/mediamtx/" + "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport tcp -i " + rtspPath + " -c:v h264_nvenc -r 25 -threads 6 -b:v 2048k -bf 0 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
+ cmd = "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport tcp -i " + rtspPath + " -c:v h264_nvenc -r 25 -threads 6 -b:v 2048k -bf 0 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH";
}
if (mode.equals("1")) {
mediaInfo.setRunondemand(cmd);
--
Gitblit v1.9.3