Add an Ubuntu badge to your video stream :)
Wow. I haven't posted a blog in quite some time. I've been focused on being a dad, husband, and better programmer. However, with the introduction of "masks" in Google+ Hangout, I've recently become obsessed with video processing and gstreamer in particular. So let me just cut to the chase:
Steps to placing an Ubuntu badge in your video stream:
1. Install Ubuntu (Precise Beta1!!)
2. Install the Video 4 Linux (v4l2loopback) driver, this will allow you to create a "virtual webcam" so-to-speak,
# sudo apt-get install v4l2loopback-dkms # sudo modprobe v4l2loopback
# wget https://help.ubuntu.com/11.10/ubuntu-help/figures/ubuntu-logo.png
4. Composite your webcam's video with a static image (the badge) and write it to the "virtual webcam" (for consumption in Google+ Hangout, for example),
The Cody Somerville-optimized version:
# gst-launch-0.10 multifilesrc location=ubuntu-logo.png caps='image/png,framerate=1/1' \ ! decodebin2 ! videobox border-alpha=0 alpha=.75 top=-80 left=-20 ! videomixer name=mix \ ! ffmpegcolorspace ! v4l2sink v4l2src ! ffmpegcolorspace ! \ 'video/x-raw-yuv,width=640, height=480' ! mix.
Here you'll see that the 'imagefreeze' plugin was scrapped for the multifilesrc which is quite clever. The multifilesrc is designed to loop through a collection of file sources at a given framerate. Here, Cody, is simply looping over the same image, faster than the eye can see. Significantly improves performance over the original version that I posted! Thanks!
# gst-launch-0.10 filesrc location=ubuntu-logo.png ! decodebin2 ! imagefreeze ! videoscale ! \ videobox border-alpha=0 alpha=.75 top=-80 left=-20 ! videomixer name=mix \ ! ffmpegcolorspace ! v4l2sink v4l2src ! videorate ! ffmpegcolorspace ! video/x-raw-yuv, \ framerate=\(fraction\)10/1, width=640, height=480 ! mix.
5. Start or join a Google+ Hangout and click on the settings icon, click on the first drop down, and choose "Loopback video device",
6. You're all done. Because this is compositing (in a manner of speaking) the image to your physical webcam video stream and writing it to the "virtual webcam", you should in theory be able to use this with any application that lets you choose your video source. Woo.
The astute Ubuntu user will notice that the logo is flipped :( This may just be a Google+ Hangout thing?
If you are a gstreamer pro, I would love to know if this could be further optimized so that I can use my native resolution without my laptop crying :)