How to record screencasts with webcam overlay on Linux

How to record screencasts with webcam overlay on Linux

If you want to record your Linux screen with a nice borderless overlay of your webcam’s image, you may use this SimpleScreenRecorder and MPlayer.

Screenshot from 2016-05-07 18:30:20.png

You can check out the official SimpleScreenRecorder website at “Download” section on how to install it. Considering you are using Ubuntu 14.04, as I am, it is quite straightforward to do:

sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder
sudo apt-get update
sudo apt-get install simplescreenrecorder

The software is, as the name says, simple to use. Just open it up and it will guide you through the recording options.

It does not have an option to show your webcam overlay, so this is the part where MPlayer comes into play.

To install MPlayer on Ubuntu 14.04, simply install it from standard repositories:

sudo apt-get install mplayer

Or, you can check MPlayer’s official website on other ways to obtain it.

To add a 320×240 borderless window streaming video from your webcam at the bottom right corner of a 1920×1080 screen, that’s the command you are looking for:

mplayer -ontop -noborder \
  -geometry 320x240+1600+840 \
  -tv driver=v4l2:width=320:height=240:device=/dev/video0 tv://

This command tells MPlayer to create a window streaming from /dev/video0 that stays on top of others, has no border, has size of 320x240px, is offset by 1600px horizontally and by 840px vertically.

You may tweak those parameters depending on your screen resolution, the desired window size and the webcam resolution.

But, don’t start making those calculations. I’ve created a simple shell script that can extract your screen resolution and correctly position the webcam overlay at the bottom right corner. Check it out on GitHub: github.com/thiago-negri/utils/blob/master/webcam_overlay.sh

If you want to record multiple workspaces, you will need to tell your window manager to keep the MPlayer window visible on all workspaces, otherwise it will only appear on one workspace. I’ve found two ways to do it on Ubuntu 14.04 using Unity window manager.

  1. After opening up the webcam overlay window, focus on it (click with your mouse on it), press Alt+Space to open the context menu and click on “Always on Visible Workspace”.
  2. Install “compizconfig-settings-manager” and “compiz-plugins”, open up compiz settings manager, enable “Windows Rules” plugin and set “Sticky” rule to “class=MPlayer”. This will make every MPlayer window to be visible on all workspaces by default.Screenshot from 2016-05-07 18:24:03.png

Now go record your own screencast and share your ideas with the world!

 

I’ve made some casual mobile games so you can have a good time even when you are not doing great stuff like recording screencasts. Check it out at games.tnegri.com.