This commit is contained in:
mofeng-git 2025-02-01 14:40:28 +00:00
parent c711683c63
commit f032b8c798
8 changed files with 54 additions and 22 deletions

View File

@ -294,7 +294,7 @@ run-build-dev:
--push
run-build-release:
$(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd -t silentwind0/kvmd:dev \
$(DOCKER) buildx build -t registry.cn-hangzhou.aliyuncs.com/silentwind/kvmd -t silentwind0/kvmd \
--progress plain \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg CACHEBUST=$(date +%s) \

View File

@ -188,15 +188,10 @@ EOF
fi
fi
# 设置默认视频模式为 mjpeg
if ! grep -q "mjpeg_default:" /etc/kvmd/override.yaml; then
cat >> /etc/kvmd/override.yaml << EOF
streamer:
mjpeg_default: true # 首次访问默认使用 MJPEG 模式
h264_bitrate: 5000 # 默认码率 5000 Kbps
EOF
log_info "已设置首次访问默认使用 MJPEG 模式"
if [ ! -z "$H264PRESET" ]; then
if sed -i "s/ultrafast/$H264PRESET/g" /etc/kvmd/override.yaml; then
log_info "H264 预设已设置为 $H264PRESET"
fi
fi
if [ ! -z "$VIDEOFORMAT" ]; then

View File

@ -5,7 +5,3 @@ audio: {
device = "hw:0"
tc358743 = "/dev/video0"
}
aplay: {
device = "plughw:UAC2Gadget,0"
check = "/run/kvmd/otg/uac2.usb0@meta.json"
}

View File

@ -66,6 +66,7 @@ kvmd:
- "--jpeg-sink-mode=0660"
- "--h264-bitrate={h264_bitrate}"
- "--h264-gop={h264_gop}"
- "--h264-preset=ultrafast"
- "--slowdown"
gpio:
drivers:

View File

@ -260,7 +260,7 @@
</td>
</tr>
<tr class="feature-disabled" id="stream-audio">
<td>Audio volume:</td>
<td i18n="kvm_text19">Audio volume:</td>
<td class="value-slider">
<input class="slider" type="range" id="stream-audio-volume-slider">
</td>

View File

@ -68,7 +68,7 @@ li(id="system-dropdown" class="right")
input(type="radio" id="stream-orient-radio-270" name="stream-orient-radio" value="270")
label(for="stream-orient-radio-270") 270&deg;
tr(id="stream-audio" class="feature-disabled")
td Audio volume:
td(i18n="kvm_text19") Audio volume:
td(class="value-slider") #[input(type="range" id="stream-audio-volume-slider" class="slider")]
td(id="stream-audio-volume-value" class="value-number")
tr(id="stream-mic" class="feature-disabled")

View File

@ -117,11 +117,6 @@ export function Streamer() {
//hidden stream-record-stop-button
document.getElementById('stream-record-stop-button').disabled = true;
// 修改这里:设置默认模式为 mjpeg
let defaultMode = "mjpeg";
let mode = tools.storage.get("stream.mode", defaultMode);
tools.radio.clickValue("stream-mode-radio", mode);
};
/************************************************************************/
@ -230,7 +225,7 @@ export function Streamer() {
tools.feature.setEnabled($("stream-mic"), false);
}
let mode = tools.storage.get("stream.mode", "mjpeg"); // 这里也改为默认 mjpeg
let mode = tools.storage.get("stream.mode", "mjpeg");
if (mode === "janus" && !has_janus) {
mode = "media";
}

View File

@ -3,6 +3,7 @@
# KVMD - The main PiKVM daemon. #
# #
# Copyright (C) 2018-2024 Maxim Devaev <mdevaev@gmail.com> #
# Copyright (C) 2023-2025 SilentWind <mofeng654321@hotmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
@ -311,6 +312,50 @@ export function JanusStreamer(__setActive, __setInactive, __setInfo, __orient, _
}
},
// 添加对 Janus 0.x 的支持
"onremotestream": function(stream) {
if (stream === null) {
// https://github.com/pikvm/pikvm/issues/1084
// 这种情况不应该发生,但有时 Janus 在 unmute 时可能会收到 null 事件
// 作为解决方案,我们重启 Janus
__logError("Got invalid onremotestream(null). Restarting Janus...");
__destroyJanus();
return;
}
let tracks = stream.getTracks();
__logInfo("Got a remote stream changes:", stream, tracks);
let has_video = false;
for (let track of tracks) {
if (track.kind == "video") {
has_video = true;
break;
}
}
if (!has_video && __isOnline()) {
// Chrome 在 ICE 状态为 disconnected 时会发送 muted 通知
// Janus.js 会从可用轨道列表中移除已静音的轨道
// 但轨道实际上仍然存在,所以可以安全地忽略这种情况
return;
}
_Janus.attachMediaStream($("stream-video"), stream);
__sendKeyRequired();
__startInfoInterval();
// FIXME: 延迟减少但在关键帧上会出现卡顿
// - https://github.com/Glimesh/janus-ftl-plugin/issues/101
/*if (__handle && __handle.webrtcStuff && __handle.webrtcStuff.pc) {
for (let receiver of __handle.webrtcStuff.pc.getReceivers()) {
if (receiver.track && receiver.track.kind === "video" && receiver.playoutDelayHint !== undefined) {
receiver.playoutDelayHint = 0;
}
}
}*/
},
"oncleanup": function() {
__logInfo("Got a cleanup notification");
__stopInfoInterval();