syncfast / clockwise

Clockwise is a meeting cost calculator designed to encourage more efficient meetings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Virtual webcam via FFMPEG

tuxuser opened this issue · comments

As a starting point..

Requirements

  • Linux system
  • v4l2loopback kernel module installed
  • ffmpeg

V4l2loopback: https://github.com/umlaeute/v4l2loopback (usually your package manager should have it)

Explaination

FONT_FILE -> User-defined font to use
TEXT_FILE -> Text file with costs stats generated by clockwise
VIDEO_NUM -> To easily distinguish virtual video source from physical

ffmpeg/v4l2loopback parameters

devices="1" -> Only generate a single virtual webcam (verbose parameter, its the default)
card_label="Clockwise Cam" -> To find the virtual webcam easily
exclusive_caps=1 -> Needed by some softwares to detect the webcam

size=1280x720 -> Essentially for Jitsi-Meet to see/use the webcam

Script

FONT_FILE="Arial.ttf"
TEXT_FILE="text.txt"

FONT_SIZE="40"
FONT_COLOR="white"

VIDEO_NUM="99"

rmmod v4l2loopback
modprobe v4l2loopback devices=1 video_nr=${VIDEO_NUM} card_label="Clockwise Cam" exclusive_caps=1

ffmpeg \
  -f lavfi \
  -i "color=black:size=1280x720,drawtext=enable=1:fontfile=${FONT_FILE}:fontsize=${FONT_SIZE}:fontcolor=${FONT_COLOR}:textfile=${TEXT_FILE}:reload=1:x=(w-text_w)/2:y=(h-text_h)/2" \
  -f v4l2 -vcodec rawvideo -pix_fmt yuv420p /dev/video${VIDEO_NUM}

EDIT 14/08/2021: Removed max_buffers=2

commented

This is amazing. Can't wait to test it out! Thank you!

Found a way to not need v4l2loopback and is multi-platform, but it comes with a caveat...

browser, err := pw.Chromium.Launch()

extend as

	browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
		Args: []string{
			"--no-sandbox",
			"--use-fake-ui-for-media-stream",
			"--use-fake-device-for-media-stream",
			"--use-file-for-fake-video-capture=/tmp/video.mjpeg",
			"--use-file-for-fake-audio-capture=/tmp/silence.wav",
		},
	})

Caveat: MJPEG does not really support being written to a FIFO, produces "Broken pipe" error.
So you would end up writing to a real file, eventually producing a rather large video file...