Last active
April 28, 2025 09:36
-
-
Save igniuss/230b84697da70a44f630e0c1438b6743 to your computer and use it in GitHub Desktop.
Simple bash script to stream directly from a USB C HDMI Dongle, including audio, currently using it to stream consoles on my PC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Streams the USB3 Video: device with matching audio using gstreamer | |
# Note: requires gstreamer v4l2src | |
# Is included in: `gst-plugins-good` | |
# usage: ./stream.sh | |
# ./stream.sh 1080 | |
resolution="width=1280, height=720" | |
if [ "$1" == "1080" ]; then | |
resolution="width=1920, height=1080" | |
fi | |
echo "Setting resolution to: $resolution" | |
devices=$(v4l2-ctl --list-devices) | |
video_device=$(echo "$devices" | awk ' | |
/^USB3 Video: USB3 Video \(.*\):/ { | |
# When we find the matching parent line | |
getline # Get the first device line | |
while ($0 ~ /^\s*\/dev\/video[0-9]+/) { | |
print $1 # Print the first video device | |
exit # Exit after the first one | |
} | |
} | |
') | |
# Output the result | |
echo "Found: $video_device as USB Device. Starting" | |
gamescope -W 2560 -H 1440 -r 120 -F fsr -S auto -b --rt --mangoapp -- gst-launch-1.0 v4l2src device=$video_device io-mode=2 \ | |
! video/x-raw, framerate=60/1, format=YUY2, $resolution \ | |
! queue max-size-buffers=1 \ | |
! videoconvert n-threads=1 \ | |
! glimagesink sync=false ts-offset=10000000 \ | |
alsasrc device=hw:CARD=Video \ # no piping here, we want to run both at the same time | |
! audioconvert \ | |
! queue max-size-buffers=1 \ | |
! autoaudiosink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment