-
Notifications
You must be signed in to change notification settings - Fork 0
/
888v.sh
26 lines (18 loc) · 1.14 KB
/
888v.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# Set the desired virtual webcam device name
device_name="888v"
# Get the Conky window ID using xwininfo
conky_window_id=$(xwininfo -tree -root | grep "conky" | grep -oP "(0x[a-z0-9]+)")
# Get the dimensions and position of the Conky window
conky_window_geometry=$(xwininfo -id "$conky_window_id" | grep "geometry" | awk '{print $2}')
# Extract the width and height of the Conky window
conky_window_width=$(echo "$conky_window_geometry" | awk -F 'x' '{print $1}')
conky_window_height=$(echo "$conky_window_geometry" | awk -F 'x' '{print $2}')
# Unload the v4l2loopback module if already loaded
sudo modprobe -r v4l2loopback
# Load the v4l2loopback module with the desired name and resolution
sudo modprobe v4l2loopback devices=1 video_nr="$device_name" width="$conky_window_width" height="$conky_window_height"
# Use FFmpeg to capture the Conky window, resize if necessary, and stream to the virtual webcam device
ffmpeg -f x11grab -i "$DISPLAY" -vf "scale=$conky_window_width:$conky_window_height" -c:v rawvideo -pix_fmt yuyv422 -f v4l2 "/dev/$device_name"
# Unload the v4l2loopback module after stopping the streaming
sudo modprobe -r v4l2loopback