#!/bin/sh # This took me far too long to figure out how to do but # I think I've learned a lot from it. What a great exercise! # These comments are for my future-self and whomever else. # -- Siina, 2020.11.09 # # Requirements: # - alsa-utils # - libv4l (brought in by USE=v4l) # - mpv # # Tools I used to figure this shit out # - arecord, aplay # - ffmpeg # - lspci # - Lots of searching through ancient fragments of the 'net # # TODO: # - Capture the exact PIDs of the launched mpv / alsaloop to prevent # shutting down any other loops / mpv that happen to be open # Set our device to 1080p otherwise it defaults to 480p v4l2-ctl --set-fmt-video=width=1920,height=1080 # Connect to capture card and display captured images immediately # Send to background so we can initiate the loop below mpv --title="Capture Card" av://v4l2:/dev/video0 --profile=low-latency --untimed & # Run a loop for the capture card digital audio to be sent to my desktop audio alsaloop -C hw:2,0 -P hw:1,0 & # Watch for mpv to exit while pgrep -f mpv >/dev/null; do continue done # Kill the alsaloop when mpv exits, then terminate this script kill -9 $(pgrep -f alsaloop) exit