| | |
| | | |
| | | @Override |
| | | public Map<String,String> addPath(String name, String sourceUrl, String mode, String isCode) { |
| | | String rtspUrl = "rtsp://" + mediamtxHost + ":7554/" + name; |
| | | String rtspUrl = "rtsp://" + mediamtxHost + ":8554/" + name; |
| | | String rtmpUrl = "rtmp://" + mediamtxHost + ":1935/" + name; |
| | | String webrtcUrl = "http://" + mediamtxHost + ":8889/" + name; |
| | | |
| | |
| | | // -i //用于指定输入媒体文件或输入流的地址 |
| | | // -bf 0 禁用B帧,因为webrtc在网页调用时控制台一直输出 WebRTC doesn’t support H264 streams with B-frames |
| | | //-f rtsp //这个选项告诉 FFmpeg 输出为 RTSP 格式。 |
| | | //-acodec opus //音频转码opus |
| | | //-acodec pcm_alaw //音频转码PCMA(G711A) |
| | | //-strict 选项用于设置音频编解码的严格级别,而 -2 是其参数之一。在早期版本的 FFmpeg 中,-strict 选项用于设置音频编解码器的行为,其中 -2 表示使用非常严格的模式。 |
| | | //CPU软解码编码 |
| | | //String cmd = rootPath + "/lib/mediamtx/" +"ffmpeg -rtsp_transport tcp -i " + rtspPath + " -vcodec libx264 -preset:v ultrafast -r 25 -threads 4 -b:v 2048k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | //GPU硬解码编码 -hwaccel cuvid -c:v h264_cuvid 使用cuda解码 -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 = "ffmpeg -rtsp_transport tcp -i " + sourceUrl + " -vcodec libx264 -preset:v ultrafast -r 25 -keyint_min 25 -g 25 -sc_threshold 0 -threads 6 -b:v 2048k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | String cmd = "ffmpeg -rtsp_transport tcp -i " + sourceUrl + " -vcodec libx264 -preset:v ultrafast -r 25 -keyint_min 25 -g 25 -sc_threshold 0 -threads 6 -b:v 2048k -acodec opus -strict -2 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | if (!softwareDecoding) { |
| | | cmd = "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport tcp -i " + sourceUrl + " -c:v h264_nvenc -r 25 -g 60 -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 " + sourceUrl + " -c:v h264_nvenc -r 25 -g 60 -threads 6 -b:v 2048k -bf 0 -acodec opus -strict -2 -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | } |
| | | if (mode.equals("0")) { |
| | | mediaInfo.setRunondemand(cmd); |
| | |
| | | |
| | | @Override |
| | | public Map<String, String> editPath(String name, String sourceUrl, String mode, String isCode) { |
| | | String rtspUrl = "rtsp://" + mediamtxHost + ":7554/" + name; |
| | | String rtspUrl = "rtsp://" + mediamtxHost + ":8554/" + name; |
| | | String rtmpUrl = "rtmp://" + mediamtxHost + ":1935/" + name; |
| | | String webrtcUrl = "http://" + mediamtxHost + ":8889/" + name; |
| | | |
| | |
| | | // -i //用于指定输入媒体文件或输入流的地址 |
| | | // -bf 0 禁用B帧,因为webrtc在网页调用时控制台一直输出 WebRTC doesn’t support H264 streams with B-frames |
| | | //-f rtsp //这个选项告诉 FFmpeg 输出为 RTSP 格式。 |
| | | //-acodec opus //音频转码opus |
| | | //CPU软解码编码 |
| | | //String cmd = rootPath + "/lib/mediamtx/" +"ffmpeg -rtsp_transport tcp -i " + rtspPath + " -vcodec libx264 -preset:v ultrafast -r 25 -threads 4 -b:v 2048k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | //GPU硬解码编码 -hwaccel cuvid -c:v h264_cuvid 使用cuda解码 -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")) { |
| | | mediaInfo.setSource("publisher"); |
| | | String cmd = "ffmpeg -rtsp_transport tcp -i " + sourceUrl + " -vcodec libx264 -preset:v ultrafast -r 25 -keyint_min 25 -g 25 -sc_threshold 0 -threads 6 -b:v 2048k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | String cmd = "ffmpeg -rtsp_transport tcp -i " + sourceUrl + " -vcodec libx264 -preset:v ultrafast -r 25 -keyint_min 25 -g 25 -sc_threshold 0 -threads 6 -b:v 2048k -acodec opus -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | if (!softwareDecoding) { |
| | | cmd = "ffmpeg -hwaccel cuvid -c:v h264_cuvid -rtsp_transport tcp -i " + sourceUrl + " -c:v h264_nvenc -r 25 -g 60 -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 " + sourceUrl + " -c:v h264_nvenc -r 25 -g 60 -threads 6 -b:v 2048k -bf 0 -acodec opus -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH"; |
| | | } |
| | | if (mode.equals("0")) { |
| | | mediaInfo.setRunondemand(cmd); |
| | |
| | | String rtmpUrl = "rtmp://" + mediamtxHost + ":1935/" + name; |
| | | info.setRtmpUrl(rtmpUrl); |
| | | //RTSP播放地址 |
| | | String rtspUrl = "rtsp://" + mediamtxHost + ":7554/" + name; |
| | | String rtspUrl = "rtsp://" + mediamtxHost + ":8554/" + name; |
| | | info.setRtspUrl(rtspUrl); |
| | | //WEBRTC播放地址 |
| | | String webrtcUrl = "http://" + mediamtxHost + ":8889/" + name; |