Skip to content
Immi Halupczok edited this page Jul 9, 2016 · 8 revisions

one of the most common causes of trouble with skype and v4l2loopback is, that skype only supports a few selected colorspaces. they probably cannot use libv4l for license issues, so they only support a few colorspaces out of the many v4l2 offers (libv4l helps incredibly, as it has converters for all v4l2 formats into a few "well known" ones)

now the v4l2loopback driver passes the colorspace without modification from producer to consumer. if your producer happens to use a colorspace that the consumer (like skype) cannot use, you are out of luck. v4l2loopback can and will not help you here (i agree with linus torvalds who says that things like colorspace conversion should not be done in kernel-space).

if a consumer cannot read your loopback device due to colorspace issues, you should do:

  • modify the consumer so it can deal with the given colorspace.
    • the easiest way is usually to use "libv4l", which is very simple (you basically replace the calls to ioctl() with calls to v4l2_ioctl() and then link your application against "libv4l2").
    • if you cannot use libv4l, add code to the consumer to deal with the colorspace explicitely
    • tell the developers of the consumer to include your changes
  • modify the producer to generate the desired colorspace.
    • e.g. when using gstreamer, use something like ffmpegcolorspace ! "video/x-raw-yuv,format=(fourcc)YUYV" in your pipeline to convert any video stream to (e.g.) YUYV format
    • when using ffmpeg, use something like -vf format=pix_fmts=yuv420p
    • ideally the producer would support multiple output formats, so you can choose the right one.
    • tell the developers of the producer to include your changes
  • if you cannot modify neither producer not consumer, you could convert the videostream using a helper-device. this is a workaround, don't use it if you can avoid it!
    • imagine, the producer can only write an YUY2-stream, but the consumer can only read RGB24-streams.
    • now let's create 2 loopback devices, using sudo modprobe v4l2loopback devices=2; let's assume they show up as /dev/video0 and dev/video1
    • tell the producer to write their YUY2-stream to the first loopback device /dev/video0
    • use gstreamer to read the YUY2-stream, convert it to RGB24 and write it to the secondary loopback device /dev/video1 with something like gstreamer-launch v4l2src device=/dev/video0 | "video/x-raw-rgb,bpp=24" | v4l2sink device=/dev/video1
    • tell the consumer to read the RGB24-stream from dev/video1
Clone this wiki locally