#!/bin/sh caffeine WIDTH="$1" HEIGHT="$2" FRAMERATE="$3" RESOLUTION="${WIDTH}x${HEIGHT}" DEVICE="/dev/$(readlink /dev/v4l/by-id/usb-MACROSILICON_USB_Video-* | head -n1 | cut -c7-)" CAPTURE_FL="$(pw-link -oI | grep 'usb-MACROSILICON_USB_Video-.*:capture_AUX0' | cut -f3 -d' ')" CAPTURE_FR="$(pw-link -oI | grep 'usb-MACROSILICON_USB_Video-.*:capture_AUX1' | cut -f3 -d' ')" DEFAULT_SINK_ALIAS="$(pw-metadata 0 default.audio.sink | grep -Po "value:'(.*?)'" | head -c-2 | cut -c8- | jq --raw-output .name)" OUTPUT_FL="$(pw-link -iI | grep "$DEFAULT_SINK_ALIAS:playback_FL" | cut -f3 -d' ')" OUTPUT_FR="$(pw-link -iI | grep "$DEFAULT_SINK_ALIAS:playback_FR" | cut -f3 -d' ')" echo "link $CAPTURE_FR -> $OUTPUT_FR" echo "link $CAPTURE_FL -> $OUTPUT_FL" pw-link "$CAPTURE_FL" "$OUTPUT_FL" pw-link "$CAPTURE_FR" "$OUTPUT_FR" v4l2-ctl -d "$DEVICE" --set-parm "$FRAMERATE" v4l2-ctl -d "$DEVICE" --set-fmt-video "width=$WIDTH,height=$HEIGHT,pixelformat=MJPG" v4l2-ctl -d "$DEVICE" --set-ctrl "brightness=0,contrast=128,saturation=128,hue=0" mpv --demuxer-lavf-format=video4linux2 \ --demuxer-lavf-o-set=input_format=mjpeg,framerate="$FRAMERATE",resolution="$RESOLUTION" \ --cache=no \ --pause=no \ --force-seekable=no \ --no-osc \ --no-input-default-bindings \ "av://v4l2:$DEVICE" # &> /dev/null & disown pw-link -d "$CAPTURE_FL" "$OUTPUT_FL" pw-link -d "$CAPTURE_FR" "$OUTPUT_FR"