Bläddra i källkod

now show screenshare via hdmi2usb adapter instead of a rtmp stream

Noah Vogt 6 månader sedan
förälder
incheckning
2cab4ed22a

+ 2 - 2
dot-config/hypr/hyprland.conf

@@ -58,7 +58,7 @@ debug {
 
 ######## Window rules ########
 windowrule = workspace 1 silent, title:^(pulpit_in)(.*)$
-windowrule = workspace 2 silent, title:^(rtmp_in)(.*)$
+windowrule = workspace 2 silent, title:^(screenshare_in)(.*)$
 
 
 ####### Keybinds ########
@@ -92,4 +92,4 @@ bind = SuperCtrl, Q, exec, killall Hyprland
 
 exec-once=[workspace 4 silent] kitty -e videopc_api
 exec-once=[workspace 4 silent] kitty -e show-rtmp-in
-exec-once=[workspace 4 silent] kitty -e show-pulpit-in
+exec-once=[workspace 4 silent] kitty -e show-screenshare-in

+ 1 - 9
local-bin/get-pulpit-device

@@ -1,14 +1,6 @@
 #!/bin/bash
 
-devices="$(v4l2-ctl --list-devices)"
-
-if echo "$devices" | grep -q "^Cam Link"; then
-    device="Cam Link"
-else
-    device="USB Video"
-fi
-
-possible_streams="$(v4l2-ctl --list-devices | grep "^$device" -A 20 | \
+possible_streams="$(v4l2-ctl --list-devices | grep "^Cam Link" -A 20 | \
                     grep "^\s*/dev/" | sed 's/^\s*//')"
 
 [ -z "$possible_streams" ] && exit

+ 11 - 0
local-bin/get-screenshare-device

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+possible_streams="$(v4l2-ctl --list-devices | grep "^USB Video" -A 20 | \
+                    grep "^\s*/dev/" | sed 's/^\s*//')"
+
+[ -z "$possible_streams" ] && exit
+
+while IFS= read -r stream; do
+    doas v4l2-ctl --device="$stream" --all | grep -q "^Video input" &&
+    echo "$stream" && exit
+done <<< "$possible_streams"

+ 3 - 4
local-bin/show-pulpit-in

@@ -1,8 +1,7 @@
 #!/bin/sh
 
 while true; do
-    mpv "$(~/.local/bin/get-pulpit-device)" --no-cache --untimed \
-        --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1 \
-        --no-resume-playback --title="pulpit_in"
-        sleep 0.5
+    mpv "$(~/.local/bin/get-pulpit-device)" \
+        --no-resume-playback --profile=low-latency --title="pulpit_in"
+    sleep 0.5
 done

+ 0 - 10
local-bin/show-rtmp-in

@@ -1,10 +0,0 @@
-#!/bin/sh
-
-RTMP_KEY="$(cat /etc/videopc_rtmp_key)"
-
-while true; do
-    mpv rtmp://localhost:1935/live/"$RTMP_KEY" --no-cache --untimed \
-        --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1 \
-        --no-resume-playback --title="rtmp_in"
-        sleep 0.5
-done

+ 7 - 0
local-bin/show-screenshare-in

@@ -0,0 +1,7 @@
+#!/bin/sh
+
+while true; do
+    mpv "$(~/.local/bin/get-screenshare-device)" \
+        --no-resume-playback --profile=low-latency --title="screenshare_in"
+    sleep 0.5
+done

+ 1 - 1
local-bin/videopc_api.py

@@ -6,7 +6,7 @@ from fastapi import FastAPI
 
 api = FastAPI()
 
-with open("/etc/videopc_api_key", "r") as api_file_reader:
+with open("/etc/videopc_api_key", "r", encoding="utf-8") as api_file_reader:
     SECRET = api_file_reader.read().strip()