Setting up webcam and screensharing at the same time for video calls

Hi, I’m TNT and I’m new in this wonderful OS. I’m trying to use it to escape the privacy nightmare that is happening nowadays, and also to improve my security. I work as a pentester and Qubes OS has brought my attention because, thanks to the Template VMs, I can create quick AppVMs with all the tooling I need to attack websites and active directory, and later do the reporting of everything.
I setup a different AppVM for every customer I have so data doesn’t get mixed and, thanks to that, customer data never leaks to other customers while showing them how to fix things in the reports or videocalls.

Today, I’m bringing a guide of how i solved a problem, and I hope this is helpful for you too. I have to say that I’m no Linux expert, I’ve moved from Windows and MacOS recently and I still have a lot of things to learn, so please, do not hate me hahaha. Also, if you have managed to get something working with better performance than this solution, please post it :pray:

So, about my problem…
I’ve started to use Qubes OS. First, it was only for hacking and I did not have any complex issue that I could not solve looking the official guides. Then I loved Qubes and started using it for everything.
When I had to deal with videocalls in MS Teams with our customers, I ran into this problem:

  • Webcam won’t work in Firefox or LibreWolf
  • I won’t be able to use Qubes Video Companion to share my screen (dom0) and my webcam at the same time. I think this issue happens because screenshare is detected as a webcam instead of a screen (it’s transmitted via /dev/videoX). This was necessary to explain my clients how I breached into some of their systems or to be able to work remotely with my colleagues and show them my findings.
  • Also, I didn’t like my webcam box in the MS Teams showing my screen, it didn’t felt right.

So, my solution is:

  1. Install QVC in dom0: sudo qubes-dom0-update qubes-video-companion-dom0
  2. Create a TemplateVM (i will use debian) for the videocall Qube.
  3. Chromium will show correctly my webcam and screenshare. In the templatevm, run: sudo apt install chromium
  4. Install Qubes Video Companion in the TemplateVM: sudo apt install qubes-video-companion
  5. Install MPV in the TemplateVM (explained later): sudo apt install mpv
  6. TemplateVM is ready. Now simply create an AppVM with this TemplateVM
  7. Now, in this AppVM, run chromium, go to MS Teams, Jitsi, Google Meet or whatever you need to use
  8. Connect your webcam to the AppVM. Doable with the GUI
  9. Now, run qubes-video-companion screenshare in the AppVM and select dom0 to be able to share your whole screen
  10. Last, we will use a webcam application to show the screensharing that we are receiving as a webcam data stream provided by QVC. First, I used Cheese and worked quite well, but the GUI of this app will take up a lot of screen space. So, I discovered that MPV tool will show a webcam without any GUI in its window. Run in the AppVM this command mpv av://v4l2:/dev/videoN --profile=low-latency --untimed. Change the N in the av://v4l2:/dev/videoN thing with the correct one. If you don’t know which one is it, try one by one until you get the screensharing in the MPV window.
  11. Now you can share your webcam in the videocall, and also use the screen share button to share the screen of the MPV window, which is your actual screen. I recommend moving the MPV window to a Workspace that you don’t use and fullscreen it there, so everything looks nice and MPV doesn’t get in your way.

And yeah, this has worked quite well for me, but I’m having a lag issue. The video of MPV lags and people see everything with delay. Also, for websites like MS Teams, everything lags because this website isn’t very efficient in performance.
If I manage to solve the lag issue, i will publish a response to this topic explaining the solution, but if someone knows of something already, i will be pleased to listen to your solution.
And if there was an easier solution to solve this, sorry. I’m new in this OS, I’m trying my best :S
Hope this makes the life easier for more users.

TNT.

2 Likes

Okay, this MAY help in performance, so video doesn’t get that laggy.

In the videocall appvm, you can do tweaks like this:

qubes-video-companion --resolution=2560x1080x10 screenshare
The last x10 in resolutions should instruct QVC to stream video with 10FPS. I prefer a not-smooth screenshare than a 10 second delayed screenshare

mpv av://v4l2:/dev/video0 --no-audio --scale=bilinear --cscale=bilinear --profile=sw-fast
Theorically, this arguments should:

  • Disable audio stream so MPV has less data to process
  • Use cheap scalings for better performance
  • Use of a fast profile to gain performance by sacrificing video quality

Again, I’m still investigating. Today’s saturday, until Monday I won’t be able to test things properly. Anyway, hope this helps.
Maybe in a future, if I learn how to code things for Qubes, I can code some kind of an extension for QVC to handle this screensharing scenario.

1 Like

Okay, this is running with only 1-2 seconds of screenshare delay, but the screen is streamable with a reasonable smoothness (showing terminal + browser + bloodhound gui), also while i can stream my webcam. anyways i try to turn off the webcam to reduce bandwidth, but it’s totally possible.

In fact, im using the MPV trick all the time I can because it’s much more comfortable to users in videocalls to view my screen there rather than in the webcam box.

Also, sometimes if i speak loudly, microphones will get “disabled”. Just run the pulse audio gui app, or the pavucontrol command to spawn the GUI. Check the input devices (microphones). Is possible that, sometimes, microphones dBs get reduces so they do not capture audio. Just re-establish the original value (100% 0 dB in my case) and everything will be solved.

So, i think i can mark this as solved :slight_smile:.
I think I won’t be posting more in this post. Hope this solves all of your videocall issues so you don’t have to worry about using qubes os in corporate environments (in fact, if your company is flexible about what OS you use, probably they will like Qubes OS, it’s had a pretty good acceptance at my company and people are starting to like the tricks qubes os enables me).

If you have questions about MPV for your personal scenarios, i recommend you checking guides of people 1000 times more pro than me using this SW to fine-tune it correctly.

Also, if you’re having performance issues in videocalls, i recommend you to make the videocall window smaller so it doesn’t consume so much CPU.

TNT

2 Likes