From 7ccac8bc9e6ea0d085344b23c12095dbebb0033d Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Mon, 25 Aug 2025 00:24:46 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0ARM64=20Rockchip?= =?UTF-8?q?=E7=A1=AC=E4=BB=B6=E5=8A=A0=E9=80=9F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 集成Rockchip MPP和RGA硬件加速库 - 添加libx264和v4l2m2m支持 - 为不同架构优化FFmpeg依赖: * AMD64: 系统FFmpeg + Intel硬件加速 * ARM: 系统FFmpeg * ARM64: 自编译FFmpeg + Rockchip硬件加速 --- build/Dockerfile | 16 +++++++----- build/Dockerfile-stage-0 | 52 ++++++++++++++++++++++++++++++-------- build/functions/install.sh | 2 +- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 0f25a274..bd9a801f 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -9,6 +9,7 @@ COPY --from=builder /tmp/ustreamer/ustreamer /tmp/ustreamer/ustreamer-dump /usr/ COPY --from=builder /tmp/wheel/*.whl /tmp/wheel/ COPY --from=builder /tmp/ustreamer/libjanus_ustreamer.so /usr/lib/ustreamer/janus/ COPY --from=builder /usr/lib/janus/transports/* /usr/lib/janus/transports/ +COPY --from=builder /opt/usr/ /usr/ ARG TARGETARCH @@ -43,12 +44,15 @@ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.lis libasound2 \ nano \ unzip \ - libavcodec59 \ - libavformat59 \ - libavutil57 \ - libswscale6 \ - libavfilter8 \ - libavdevice59 \ + && if [ ${TARGETARCH} != arm64 ]; then \ + apt-get install -y --no-install-recommends \ + libavcodec59 \ + libavformat59 \ + libavutil57 \ + libswscale6 \ + libavfilter8 \ + libavdevice59; \ + fi \ && if [ ${TARGETARCH} != arm ] && [ ${TARGETARCH} != arm64 ]; then \ apt-get install -y --no-install-recommends \ ffmpeg \ diff --git a/build/Dockerfile-stage-0 b/build/Dockerfile-stage-0 index 278e5712..0a72b6f3 100644 --- a/build/Dockerfile-stage-0 +++ b/build/Dockerfile-stage-0 @@ -49,27 +49,36 @@ RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/' /etc/apt/sources.lis libusb-1.0-0-dev \ libldap2-dev \ libsasl2-dev \ - ffmpeg \ - libavcodec-dev \ - libavformat-dev \ - libavutil-dev \ - libswscale-dev \ - libavfilter-dev \ - libavdevice-dev \ - vainfo \ - libva-dev \ - libva-drm2 \ - libva-x11-2 \ libdrm-dev \ mesa-va-drivers \ mesa-vdpau-drivers \ v4l-utils \ libv4l-dev \ + && if [ ${TARGETARCH} != arm64 ]; then \ + apt-get install -y --no-install-recommends \ + ffmpeg \ + libavcodec-dev \ + libavformat-dev \ + libavutil-dev \ + libswscale-dev \ + libavfilter-dev \ + libavdevice-dev; \ + fi \ && if [ ${TARGETARCH} != arm ] && [ ${TARGETARCH} != arm64 ]; then \ apt-get install -y --no-install-recommends \ + vainfo \ + libva-dev \ + libva-drm2 \ + libva-x11-2 \ intel-media-va-driver \ i965-va-driver; \ fi \ + && if [ ${TARGETARCH} = arm64 ]; then \ + apt-get install -y --no-install-recommends \ + ninja-build \ + zlib1g-dev \ + libswresample-dev; \ + fi \ && apt clean \ && rm -rf /var/lib/apt/lists/* @@ -131,6 +140,27 @@ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libn && cd /tmp \ && rm -rf /tmp/janus-gateway +# 编译 Rockchip MPP、RGA 和 FFmpeg(仅 arm64) +RUN if [ ${TARGETARCH} = arm64 ]; then \ + git clone --depth=1 https://github.com/rockchip-linux/mpp.git /tmp/mpp \ + && cd /tmp/mpp \ + && cmake -DRKPLATFORM=ON -DCMAKE_INSTALL_PREFIX=/usr . \ + && make -j$(nproc) \ + && make install \ + && make install DESTDIR=/opt \ + && git clone --depth=1 -b 1.9.1 https://github.com/airockchip/librga /tmp/librga \ + && cd /tmp/librga \ + && meson setup --prefix=/usr rkrga_build \ + && ninja -C rkrga_build install \ + && DESTDIR=/opt ninja -C rkrga_build install \ + && git clone --depth=1 https://github.com/nyanmisaka/ffmpeg-rockchip.git /tmp/ffmpeg-rockchip \ + && cd /tmp/ffmpeg-rockchip \ + && ./configure --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga --enable-alsa --enable-libv4l2 --enable-libx264 --enable-v4l2-m2m --disable-programs \ + && make -j$(nproc) \ + && make install \ + && make install DESTDIR=/opt; \ + fi + # 编译 ustreamer RUN echo "Building ustreamer with timestamp cache bust" \ && sed --in-place --expression 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h \ diff --git a/build/functions/install.sh b/build/functions/install.sh index ba4acb0d..5b49d5ed 100755 --- a/build/functions/install.sh +++ b/build/functions/install.sh @@ -108,7 +108,7 @@ install_base_packages() { iptables network-manager curl kmod libmicrohttpd12 libjansson4 libssl3 \\ libsofia-sip-ua0 libglib2.0-0 libopus0 libogg0 libcurl4 libconfig9 \\ python3-pip net-tools libavcodec59 libavformat59 libavutil57 libswscale6 \\ - libavfilter8 libavdevice59 v4l-utils libv4l-0 && \\ + libavfilter8 libavdevice59 v4l-utils libv4l-0 nano unzip && \\ apt clean && \\ rm -rf /var/lib/apt/lists/* " From ccdfd52b75ee1b2e05e4a51fb9c6aba130f6f246 Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Mon, 25 Aug 2025 01:00:22 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3libwebsockets?= =?UTF-8?q?=E7=9A=84=E5=85=8B=E9=9A=86=E5=9C=B0=E5=9D=80=E4=B8=BAGitHub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Dockerfile-stage-0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Dockerfile-stage-0 b/build/Dockerfile-stage-0 index 0a72b6f3..163b39c7 100644 --- a/build/Dockerfile-stage-0 +++ b/build/Dockerfile-stage-0 @@ -123,7 +123,7 @@ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libn && make shared_library -j && make install \ && cd /tmp \ && rm -rf /tmp/libsrtp* \ - && git clone --depth=1 https://libwebsockets.org/repo/libwebsockets /tmp/libwebsockets \ + && git clone --depth=1 https://github.com/warmcat/libwebsockets /tmp/libwebsockets \ && cd /tmp/libwebsockets \ && mkdir build && cd build \ && cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. \ From ecc27c2be7cd45c0ea31878936c9f7d0b851c5c3 Mon Sep 17 00:00:00 2001 From: mofeng-git Date: Mon, 25 Aug 2025 20:14:50 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DMSD=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8A=9F=E8=83=BD=E5=92=8C=E5=A4=9A=E9=A1=B9=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复MSD上传中prefix参数编码问题 - 移除重复的uploading-sub元素定义 - 优化Python依赖库清理和缓存管理 - 改进Rockchip硬件加速库构建流程 - 增强国际化语言检测和设置 - 修正ttyd下载地址和系统服务配置 --- build/Dockerfile | 9 +++++--- build/Dockerfile-stage-0 | 44 +++++++++++++++++++++++-------------- build/functions/install.sh | 5 ++--- web/kvm/index.html | 3 --- web/kvm/navbar-msd.pug | 4 +--- web/share/i18n/i18n_en.json | 1 + web/share/i18n/i18n_zh.json | 1 + web/share/js/i18n/i18n.js | 34 +++++++++++++++++++--------- web/share/js/kvm/msd.js | 4 ++-- 9 files changed, 65 insertions(+), 40 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index bd9a801f..3b3abcd8 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -4,14 +4,17 @@ FROM python:3.11.11-slim-bookworm LABEL maintainer="mofeng654321@hotmail.com" +ARG TARGETARCH + COPY --from=builder /tmp/lib/* /tmp/lib/ COPY --from=builder /tmp/ustreamer/ustreamer /tmp/ustreamer/ustreamer-dump /usr/bin/janus /usr/bin/ COPY --from=builder /tmp/wheel/*.whl /tmp/wheel/ COPY --from=builder /tmp/ustreamer/libjanus_ustreamer.so /usr/lib/ustreamer/janus/ COPY --from=builder /usr/lib/janus/transports/* /usr/lib/janus/transports/ -COPY --from=builder /opt/usr/ /usr/ - -ARG TARGETARCH +COPY --from=builder /tmp/arm64-libs.tar.gz /tmp/ +RUN if [ ${TARGETARCH} = arm64 ]; then \ + cd / && tar -xzf /tmp/arm64-libs.tar.gz && rm -f /tmp/arm64-libs.tar.gz; \ + fi ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ diff --git a/build/Dockerfile-stage-0 b/build/Dockerfile-stage-0 index 163b39c7..7f51837c 100644 --- a/build/Dockerfile-stage-0 +++ b/build/Dockerfile-stage-0 @@ -103,12 +103,18 @@ RUN --security=insecure pip config set global.index-url https://pypi.tuna.tsingh pycparser pyelftools pyghmi pygments pyparsing pyotp qrcode requests \ semantic-version setproctitle six spidev tabulate urllib3 wrapt xlib \ yarl pyserial pyyaml zstandard supervisor pyfatfs pyserial python-periphery \ - python-ldap python-pam pyrad pyudev pyusb luma.oled pyserial-asyncio + python-ldap python-pam pyrad pyudev pyusb luma.oled pyserial-asyncio \ + && rm -rf /root/.cache/pip/* /tmp/pip-* \ + && if [ ${TARGETARCH} = arm ]; then \ + umount /root/.cargo 2>/dev/null || true \ + && rm -rf /root/.cargo /root/rustup-init.sh; \ + fi -# 编译 python vedev库 +# 编译 python evdev库 RUN git clone --depth=1 https://github.com/gvalkov/python-evdev.git /tmp/python-evdev \ && cd /tmp/python-evdev \ - && python3 setup.py bdist_wheel --dist-dir /tmp/wheel/ + && python3 setup.py bdist_wheel --dist-dir /tmp/wheel/ \ + && rm -rf /tmp/python-evdev # 编译安装 libnice、libsrtp、libwebsockets 和 janus-gateway RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libnice \ @@ -120,14 +126,14 @@ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libn && tar xf libsrtp-2.2.0.tar.gz \ && cd libsrtp-2.2.0 \ && ./configure --prefix=/usr --enable-openssl \ - && make shared_library -j && make install \ + && make shared_library -j$(nproc) && make install \ && cd /tmp \ && rm -rf /tmp/libsrtp* \ && git clone --depth=1 https://github.com/warmcat/libwebsockets /tmp/libwebsockets \ && cd /tmp/libwebsockets \ && mkdir build && cd build \ && cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" .. \ - && make -j && make install \ + && make -j$(nproc) && make install \ && cd /tmp \ && rm -rf /tmp/libwebsockets \ && git clone --depth=1 https://github.com/meetecho/janus-gateway.git /tmp/janus-gateway \ @@ -136,29 +142,35 @@ RUN git clone --depth=1 https://gitlab.freedesktop.org/libnice/libnice /tmp/libn && ./configure --enable-static --enable-websockets --enable-plugin-audiobridge \ --disable-data-channels --disable-rabbitmq --disable-mqtt --disable-all-plugins \ --disable-all-loggers --prefix=/usr \ - && make -j && make install \ + && make -j$(nproc) && make install \ && cd /tmp \ && rm -rf /tmp/janus-gateway # 编译 Rockchip MPP、RGA 和 FFmpeg(仅 arm64) RUN if [ ${TARGETARCH} = arm64 ]; then \ - git clone --depth=1 https://github.com/rockchip-linux/mpp.git /tmp/mpp \ - && cd /tmp/mpp \ - && cmake -DRKPLATFORM=ON -DCMAKE_INSTALL_PREFIX=/usr . \ + git clone -b jellyfin-mpp --depth=1 https://github.com/nyanmisaka/mpp.git /tmp/rkmpp \ + && mkdir -p /tmp/rkmpp/rkmpp_build && cd /tmp/rkmpp/rkmpp_build \ + && cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_TEST=OFF .. \ && make -j$(nproc) \ && make install \ && make install DESTDIR=/opt \ - && git clone --depth=1 -b 1.9.1 https://github.com/airockchip/librga /tmp/librga \ - && cd /tmp/librga \ - && meson setup --prefix=/usr rkrga_build \ + && git clone -b jellyfin-rga --depth=1 https://github.com/nyanmisaka/rk-mirrors.git /tmp/rkrga \ + && cd /tmp/ \ + && meson setup rkrga rkrga_build --prefix=/usr --libdir=lib --buildtype=release -Dcpp_args=-fpermissive -Dlibdrm=false -Dlibrga_demo=false \ + && meson configure rkrga_build > /dev/null \ && ninja -C rkrga_build install \ && DESTDIR=/opt ninja -C rkrga_build install \ - && git clone --depth=1 https://github.com/nyanmisaka/ffmpeg-rockchip.git /tmp/ffmpeg-rockchip \ + && git clone https://github.com/nyanmisaka/ffmpeg-rockchip.git /tmp/ffmpeg-rockchip \ && cd /tmp/ffmpeg-rockchip \ - && ./configure --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga --enable-alsa --enable-libv4l2 --enable-libx264 --enable-v4l2-m2m --disable-programs \ + && ./configure --prefix=/usr --enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga \ + --enable-libv4l2 --enable-libx264 --enable-shared --disable-programs \ + --disable-doc --disable-htmlpages --disable-manpages --disable-network --disable-protocols \ + --disable-decoders --disable-debug --disable-alsa \ && make -j$(nproc) \ && make install \ - && make install DESTDIR=/opt; \ + && make install DESTDIR=/opt \ + && cd /opt && tar -czf /tmp/arm64-libs.tar.gz usr/ \ + && rm -rf /tmp/rkmpp /tmp/rkrga /tmp/ffmpeg-rockchip /opt/usr; \ fi # 编译 ustreamer @@ -166,7 +178,7 @@ RUN echo "Building ustreamer with timestamp cache bust" \ && sed --in-place --expression 's|^#include "refcount.h"$|#include "../refcount.h"|g' /usr/include/janus/plugins/plugin.h \ && TIMESTAMP=$(date +%s%N) \ && git clone --depth=1 https://github.com/mofeng-git/ustreamer /tmp/ustreamer-${TIMESTAMP} \ - && make -j WITH_PYTHON=1 WITH_JANUS=1 WITH_FFMPEG=1 -C /tmp/ustreamer-${TIMESTAMP} \ + && make -j$(nproc) WITH_PYTHON=1 WITH_JANUS=1 WITH_FFMPEG=1 -C /tmp/ustreamer-${TIMESTAMP} \ && /tmp/ustreamer-${TIMESTAMP}/ustreamer -v \ && cp /tmp/ustreamer-${TIMESTAMP}/python/dist/*.whl /tmp/wheel/ \ && mv /tmp/ustreamer-${TIMESTAMP} /tmp/ustreamer diff --git a/build/functions/install.sh b/build/functions/install.sh index 5b49d5ed..62932815 100755 --- a/build/functions/install.sh +++ b/build/functions/install.sh @@ -180,9 +180,8 @@ configure_system() { cat /One-KVM/configs/os/udev/v2-hdmiusb-rpi4.rules > /etc/udev/rules.d/99-kvmd.rules && \\ echo 'libcomposite' >> /etc/modules && \\ mv /usr/local/bin/kvmd* /usr/bin/ || echo '信息:/usr/local/bin/kvmd* 未找到或移动失败,可能已在/usr/bin' && \\ - cp /One-KVM/configs/os/services/* /etc/systemd/system/ && \\ + cp -r /One-KVM/configs/os/services/* /etc/systemd/system/ && \\ cp /One-KVM/configs/os/tmpfiles.conf /usr/lib/tmpfiles.d/ && \\ - mv /etc/kvmd/supervisord.conf /etc/supervisord.conf && \\ chmod +x /etc/update-motd.d/* || echo '警告:chmod /etc/update-motd.d/* 失败' && \\ echo 'kvmd ALL=(ALL) NOPASSWD: /etc/kvmd/custom_atx/gpio.sh' >> /etc/sudoers && \\ echo 'kvmd ALL=(ALL) NOPASSWD: /etc/kvmd/custom_atx/usbrelay_hid.sh' >> /etc/sudoers && \\ @@ -210,7 +209,7 @@ install_webterm() { echo "信息:在 chroot 环境中下载并安装 ttyd ($ttyd_arch)..." run_in_chroot " - curl -L https://gh.llkk.cc/https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${ttyd_arch} -o /usr/bin/ttyd && \\ + curl -L https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${ttyd_arch} -o /usr/bin/ttyd && \\ chmod +x /usr/bin/ttyd && \\ mkdir -p /home/kvmd-webterm && \\ chown kvmd-webterm /home/kvmd-webterm diff --git a/web/kvm/index.html b/web/kvm/index.html index 263f1ae4..c2035496 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -719,9 +719,6 @@ -