Skip to content

Virtual webcam via FFMPEG #9

Description

@tuxuser

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions