Gabriel
Gabriel

Reputation: 111

Google chrome cannot detect v4l2loopback device

I'm trying to transmit my screen using ffmpeg and v4l2loopback, more when running the commands:

sudo modprobe v4l2loopback devices=1 video_nr=2 card_label="Camera Loopback"

and

ffmpeg -f x11grab -framerate 30 -video_size 1366x768 -i :0.0 -f v4l2 /dev/video2

chrome does not detect the device in: /dev/video2, I tried everything to make it work, but chrome does not detect it, I tried to add the filter:

-vf format=pix_fmts=yuv420p

but still nothing.

Chrome: 87.0.4280.66 (64bit)
OS: LinuxMint 19.3
v4l2loopback: 0.12.3

If anyone can help me, thank you in advance!.

Upvotes: 4

Views: 1768

Answers (2)

Gabriel
Gabriel

Reputation: 111

Load videodev module:

sudo modprobe videodev

Load v4l2 loopback:

sudo modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1 card_label="ExternalWebCam"

Important Details: Chrome, only accepts buffers in yuv420p pixel format, which makes a lot of sense, since the cameras have this pixel format as standard.

Use example:

ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2

This command, stream the screen to /dev/video2 device, created by v4l2loopback

Upvotes: 5

rogeriojlle
rogeriojlle

Reputation: 1066

Note the parameter "exclusive_caps", necessary to work in Chrome, see my script as an example, it creates three cameras

#!/bin/sh

MODULE_OPTIONS="devices=3 video_nr=11,12,13 exclusive_caps=1,1,1 card_label=X_11,X_12,X_13"

rmmod v4l2loopback 2> /dev/null
modprobe videodev
insmod ./v4l2loopback.ko ${MODULE_OPTIONS}

Upvotes: 1

Related Questions