🐛 fix(base): Device selection patch for gpu-screen-recorder (#93)

## Description

Adds new `-device` argument for gpu-screen-recorder which allows
specifying a GPU to use (by `/dev/dri/cardN` path)

This fixes an issue with multi-gpu systems when device such as
`/dev/dri/card1` is passed through but gpu-screen-recorder will still
try to access `/dev/dri/card0` for capturing and failing.

Added relevant bits to `gpu_helpers.sh` to find the card path - I assume
all modern modesetting drivers will have a `/drm/` path that tells the
card number. If not, the script will fall back to gpu-screen-recorder's
own method of finding the card.

Edit: Forgot to mention patches are now copied to /tmp/ rather than
/etc/

Co-authored-by: Kristian Ollikainen <DatCaptainHorse@users.noreply.github.com>
This commit is contained in:
Kristian Ollikainen
2024-07-07 12:43:58 +03:00
committed by GitHub
parent cf69f6c93a
commit 3df53e7e38
4 changed files with 70 additions and 3 deletions

View File

@@ -115,6 +115,16 @@ selected_gpu_vendor=$(get_gpu_vendor "$selected_gpu")
# Convert lshw gathered bus id into Xorg compatible one
xorg_bus_id=$(get_gpu_bus_xorg "$selected_gpu")
# Get GPU card path if available
selected_gpu_card=""
gpu_screen_recorder_device_arg=""
card_result=$(get_gpu_card "$selected_gpu")
if [[ $? -eq 0 && -n "$card_result" ]]; then
selected_gpu_card="$card_result"
gpu_screen_recorder_device_arg="-device $selected_gpu_card"
fi
# Check if the selected GPU is an NVIDIA GPU
if [[ "${selected_gpu_vendor,,}" =~ "nvidia" ]]; then
echo "Selected GPU is NVIDIA. Handling NVIDIA-specific configuration..."
@@ -264,7 +274,7 @@ sudo chown nestri:nestri /usr/bin/gpu-screen-recorder
if [[ -z "${SESSION_ID}" ]]; then
echo "$(date +"[%Y-%m-%d %H:%M:%S]") No stream name was found, did you forget to set the env variable NAME?" && exit 1
else
/usr/bin/gpu-screen-recorder -v no -w screen -c flv -f "${REFRESH}" -a "$(pactl get-default-sink).monitor" | ffmpeg -hide_banner -v quiet -i pipe:0 -c copy -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - | /usr/bin/warp --name "${SESSION_ID}" https://fst.so:4443 &
/usr/bin/gpu-screen-recorder $gpu_screen_recorder_device_arg -v no -w screen -c flv -f "${REFRESH}" -a "$(pactl get-default-sink).monitor" | ffmpeg -hide_banner -v quiet -i pipe:0 -c copy -f mp4 -movflags empty_moov+frag_every_frame+separate_moof+omit_tfhd_offset - | /usr/bin/warp --name "${SESSION_ID}" https://fst.so:4443 &
fi
openbox-session &