From 408a627c08ec17ac0e7f25993cf69023743c9abf Mon Sep 17 00:00:00 2001 From: Wanjohi <71614375+wanjohiryan@users.noreply.github.com> Date: Sat, 20 Apr 2024 01:23:05 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Capture=20screen=20and=20se?= =?UTF-8?q?nd=20with=20warp=20(#26)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description **What(what issue does this code solve/what feature does it add):** **How(how does it solve it):** ## Required Checklist: - [ ] I have added any necessary documentation and comments in my code (where appropriate) - [ ] I have added tests to make sure my code runs in all contexts ## Further comments --- .dev/{x11.sh => script.sh} | 4 ++++ .scripts/entrypoint.sh | 8 ++++++++ server.Dockerfile | 2 ++ 3 files changed, 14 insertions(+) rename .dev/{x11.sh => script.sh} (66%) diff --git a/.dev/x11.sh b/.dev/script.sh similarity index 66% rename from .dev/x11.sh rename to .dev/script.sh index f684eb72..1d0f332a 100644 --- a/.dev/x11.sh +++ b/.dev/script.sh @@ -14,3 +14,7 @@ weston --backend=wayland-backend.so #Run docker run --gpus all --entrypoint /bin/bash --rm -it -v $(pwd):/games -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --cap-add=SYS_NICE --cap-add=SYS_ADMIN recorder + +docker run --gpus all --entrypoint /bin/bash --device=/dev/dri --rm -it -v $(pwd):/game --cap-add=SYS_NICE --cap-add=SYS_ADMIN ghcr.io/wanjohiryan/netris/server:nightly + + ffmpeg -hide_banner -v quiet -stream_loop -1 -re -i /game/test.mp4 -an -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - | RUST_LOG=moq_pub=info warp --name "netris" https://fst.so:4443 \ No newline at end of file diff --git a/.scripts/entrypoint.sh b/.scripts/entrypoint.sh index 596e9b2b..6e4d41a0 100644 --- a/.scripts/entrypoint.sh +++ b/.scripts/entrypoint.sh @@ -109,5 +109,13 @@ echo "Waiting for X socket" until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done echo "X socket is ready" +if [[ -z "${NAME}" ]]; then + echo "No stream name was found, did you forget to set the env variable NAME?" && exit 1 +else + /usr/bin/gpu-screen-recorder -w screen -c flv -f 60 -a "$(pactl get-default-sink).monitor" | ffmpeg -i pipe:0 -c copy -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - | /usr/bin/warp --name "${NAME}" https://fst.so:4443 & +fi +# /usr/bin/gpu-screen-recorder -w screen -c flv -f 60 -a "$(pactl get-default-sink).monitor" | ffmpeg -i pipe:0 -c copy -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - | /usr/bin/warp --name "bbb" https://fst.so +/usr/games/g amescope -h 720 -H 1080 -F fsr -f -- mangohud glxgears > /dev/null & + echo "Session Running. Press [Return] to exit." read diff --git a/server.Dockerfile b/server.Dockerfile index c967f4f4..0835ea7f 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -16,8 +16,10 @@ ENV TZ=UTC \ RUN apt-get update -y \ && add-apt-repository -y multiverse \ && apt-get install -y --no-install-recommends \ + libxnvctrl0 \ mangohud \ gamescope \ + && setcap cap_sys_nice+ep /usr/games/gamescope \ && rm -rf /var/lib/apt/lists/* #Install wine