2020-11-10 01:04:20 +02:00
|
|
|
#!/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:
|
|
|
|
# - libv4l (brought in by USE=v4l)
|
|
|
|
# - mpv
|
|
|
|
|
2021-01-23 12:23:17 +02:00
|
|
|
## 0 - Find input and output sources with pactl
|
|
|
|
input="alsa_input.usb-AVerMedia_AVerMedia_USB_Device_52030300003520-02.iec958-stereo"
|
|
|
|
output="alsa_output.pci-0000_0b_00.4.analog-stereo"
|
|
|
|
|
|
|
|
## 1 - Configure video
|
2020-11-10 01:04:20 +02:00
|
|
|
# Set our device to 1080p otherwise it defaults to 480p
|
|
|
|
v4l2-ctl --set-fmt-video=width=1920,height=1080
|
|
|
|
|
2021-01-23 12:23:17 +02:00
|
|
|
## 2 - Launch viewer
|
2020-11-10 01:04:20 +02:00
|
|
|
# Connect to capture card and display captured images immediately
|
|
|
|
# Send to background so we can initiate the loop below
|
2020-12-02 05:19:20 +02:00
|
|
|
mpv --title="Capture Card" av://v4l2:/dev/video0 --profile=low-latency --untimed &
|
2020-11-10 01:04:20 +02:00
|
|
|
|
2021-01-23 12:23:17 +02:00
|
|
|
## 3 - Connect audio, send to background for loop
|
|
|
|
pacat -r --latency-msec=1 -d $input | pacat -p --latency-msec=1 -d $output &
|
2020-12-02 05:19:20 +02:00
|
|
|
|
2021-01-23 12:23:17 +02:00
|
|
|
## 4 - Cleanup
|
2020-12-02 05:19:20 +02:00
|
|
|
# Watch for mpv to exit
|
|
|
|
while pgrep -f mpv >/dev/null; do
|
2021-01-23 12:23:17 +02:00
|
|
|
sleep 3
|
2020-12-02 05:19:20 +02:00
|
|
|
continue
|
|
|
|
done
|
2020-11-10 01:04:20 +02:00
|
|
|
|
2021-01-23 12:23:17 +02:00
|
|
|
# Kill pacat since it's not needed
|
|
|
|
kill -9 $(pgrep -f pacat)
|
2020-11-10 01:04:20 +02:00
|
|
|
exit
|