集成 WebRTC/H.264 支持

This commit is contained in:
mofeng-git 2024-09-11 10:32:45 +08:00
parent 8f0a591c98
commit 0ff678a495
6 changed files with 7044 additions and 15 deletions

View File

@ -28,14 +28,15 @@ RUN pip install --no-cache-dir --root-user-action=ignore --disable-pip-version-c
pyelftools pyghmi pygments pyparsing pyotp qrcode requests semantic-version setproctitle setuptools six spidev \
tabulate urllib3 wrapt xlib yarl pyserial pyyaml zstandard supervisor
RUN git clone --depth=1 https://gh.xmly.dev/https://github.com/pikvm/ustreamer /tmp/ustreamer \
#&& git clone --depth=1 https://github.com/pikvm/ustreamer /tmp/ustreamer \
&& make -j WITH_PYTHON=1 -C /tmp/ustreamer \
RUN apt-get install -y libx264-dev libyuv-dev janus-dev libasound2-dev libspeex-dev libspeexdsp-dev libopus-dev \
&& sed --in-place --expression 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h \
&& git clone --depth=1 https://github.com/mofeng-git/ustreamer /tmp/ustreamer \
&& make -j WITH_PYTHON=1 WITH_JANUS=1 WITH_LIBX264=1 -C /tmp/ustreamer \
&& /tmp/ustreamer/ustreamer -v
RUN mkdir /tmp/lib \
&& cp /lib/*-linux-*/libevent_core-*.so.7 /lib/*-linux-*/libbsd.so.0 /lib/*-linux-*/libevent_pthreads-*.so.7 \
/lib/*-linux-*/libevent-*.so.7 /lib/*-linux-*/libjpeg.so.62 /tmp/lib/ \
&& cp /lib/*-linux-*/libevent_core-*.so.7 /lib/*-linux-*/libbsd.so.0 /lib/*-linux-*/libevent_pthreads-*.so.7 /lib/*-linux-*/libspeexdsp.so.1 \
/lib/*-linux-*/libevent-*.so.7 /lib/*-linux-*/libjpeg.so.62 /lib/*-linux-*/libx264.so.164 /lib/*-linux-*/libyuv.so.0 /lib/*-linux-*/libasound.so.2 /tmp/lib/ \
&& cp /tmp/ustreamer/python/dist/*.whl /tmp/wheel/
FROM python:3.12.0rc2-slim-bookworm
@ -45,6 +46,8 @@ LABEL maintainer="mofeng654321@hotmail.com"
COPY --from=builder /tmp/lib/* /tmp/lib/
COPY --from=builder /tmp/ustreamer/ustreamer /tmp/ustreamer/ustreamer-dump /usr/local/bin/
COPY --from=builder /tmp/wheel/*.whl /tmp/wheel/
COPY --from=builder /tmp/ustreamer/libjanus_ustreamer.so /usr/lib/ustreamer/janus/
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
@ -56,7 +59,7 @@ RUN cp /tmp/lib/* /lib/*-linux-*/ \
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.list.d/debian.sources \
&& apt-get update \
&& apt-get install -y --no-install-recommends libxkbcommon-x11-0 nginx tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim iptables sudo \
&& apt-get install -y --no-install-recommends libxkbcommon-x11-0 nginx tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim iptables sudo janus \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p \
@ -78,9 +81,11 @@ COPY contrib/keymaps /usr/share/kvmd/keymaps
COPY kvmd/ /kvmd
COPY configs/kvmd/* /etc/kvmd/
COPY configs/nginx/* /etc/kvmd/nginx/
COPY configs/janus/* /etc/kvmd/janus/
COPY configs/hw_info/* /etc/kvmd/hw_info/
COPY build/v2-hdmiusb-rpi4.override.yaml /etc/kvmd/override.yaml
COPY configs/kvmd/main/v2-hdmiusb-rpi4.yaml /etc/kvmd/main.yaml
COPY testenv/js/* /usr/share/janus/javascript/
RUN touch /run/kvmd/ustreamer.sock /etc/kvmd/.docker_flag \
&& adduser kvmd --gecos "" --disabled-password \

View File

@ -18,6 +18,7 @@ kvmd:
- "--device=/dev/kvmd-video"
- "--persistent"
- "--format=mjpeg"
- "--encoder=LIBX264-VIDEO"
- "--resolution={resolution}"
- "--desired-fps={desired_fps}"
- "--drop-same-frames=30"
@ -29,6 +30,10 @@ kvmd:
- "--process-name-prefix={process_name_prefix}"
- "--notify-parent"
- "--no-log-colors"
- "--h264-sink=kvmd::ustreamer::h264"
- "--h264-sink-mode=0660"
- "--jpeg-sink=kvmd::ustreamer::jpeg"
- "--jpeg-sink-mode=0660"
vnc:
keymap: /usr/share/kvmd/keymaps/ru
@ -39,9 +44,9 @@ vnc:
memsink:
jpeg:
sink: ""
sink: "kvmd::ustreamer::jpeg"
h264:
sink: ""
sink: "kvmd::ustreamer::h264"
otgnet:
commands:
@ -56,9 +61,6 @@ nginx:
https:
port: 4430
janus:
cmd:
- "/bin/true"
languages:
console: zh

View File

@ -1,7 +1,4 @@
video: {
sink = "kvmd::ustreamer::h264"
}
audio: {
device = "hw:0,0"
tc358743 = "/dev/kvmd-video"
}

View File

@ -47,6 +47,16 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes = 0
redirect_stderr=true
[program:kvmd-janus]
command=python -m kvmd.apps.janus --run
autostart=true
autorestart=true
priority=13
stopasgroup=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes = 0
redirect_stderr=true
[program:kvmd-nginx]
command=nginx -c /etc/kvmd/nginx/nginx.conf -g 'daemon off;user root; error_log stderr;'
autostart=true

3364
testenv/js/adapter.js Normal file

File diff suppressed because it is too large Load Diff

3651
testenv/js/janus.js Normal file

File diff suppressed because it is too large Load Diff