A lot has happened since I posted my ugly hacks required to take advantage of the H.264 compressor in the Logitech C920 webcam. Gstreamer 1.2 now includes a uvch264src that can be used to read H.264 encoded video stream from the camera eliminating the need for an external capture application.
You may already know about my existing enthusiasm for Logitech webcams, which is due to the combination of relatively good image quality, high resolution and easy to use UVC interface. I was therefore very happy to learn about their newest camera, the HD Pro Webcam C920, which in addition to the standard HD webcam stuff we already know from the C910, also provides hardware encoded H.264 video stream! This is rather new and there isn’t much software that can take advantage of it; however, with a little tweaking and hacking we can get the H.264 stream into Gstreamer, where after we can do pretty much whatever we want.
Back in August 2010 I ran a brief experiment using GstInputSelector to switch between various video sources. You may have noticed that it was using Theora encoder while most of my other DVB experiments used H.264 encoder in MPEG-TS container. The reason for this was that I could not make x264enc work in the pipeline used for the video switcher.
Up until now I have been using the standard (link) YUV 4:2:2 pixel format with my Logitech Webcam Pro 9000. This format is good for most cases; however, the framerate is limited to 15/2 fps at 1280×720 resolution, while the other supported formats (MJPG, RGB3, BGR3, YU12, YV12) support this reolution with up to 30 fps! So it was time for me to figure it out.
An email on the gst-devel mailing list last week pointed me to a rather interesting example in the gst-python repository: switch.py – shows how to use the GstInputSelector element in a Python script to select between different input streams. When I looked at the example I thought right away that it would be cool to use it to switch between different cameras in my simple DVB setup that uses Gstreamer and GNU Radio.
Recording audio with gstreamer is easy:
gst-launch -e pulsesrc ! audioconvert ! \
lamemp3enc target=1 bitrate=64 cbr=true ! \
The pulsesrc element here refers to the pulseaudio input (pulseaudio is AFAIK the default sound system in all linux distributions nowadays). This is good and will capture audio from the default sound input, which can be microphone or line-in depending on the hardware and the pulseaudio configuration.
But what if I plug in my USB webcam with built-in microphone and I want to capture audio from that?
Few weeks agio I posted my notes about picture-in-picture compositing in Gstreamer using nothing else than the gst-launch command line tool. I also wrote that I could not figure out how to use the xpos, ypos, zorder properties of the GstVideoMixerPad element. I got a comment on this note from Jan Schmidt telling that these properties can not be used with gst-launch but are easily accessible from Python. He also gave a very cool example that shows how to use it.
In a previous post I gave a few examples showing how simple text overlays can be added to any video stream in GStreamer. Now it’s time to look at compositing between two or more video streams, also called picture in picture. As you’ll see it is still very easy to achieve even when using nothing more than the gst-launch command line tool. First we look at some basic examples, then we finish with a more complex “Live from Pluto” video wall.
I have experienced an unexpected spin-off while fooling around with GStreamer and my Logitech QuickCam Vision Pro 9000 webcam: A simple and easy way to autonomously capture and render time-lapse videos.
One of the advantages of webcams compared to other digital still and video cameras is that it can be controlled from a computer and the captured frames are transfered from the camera to the computer in real-time using the USB interface. This is pretty much the definition of a webcam and this feature is indeed very convenient for capturing time-lapse videos. Unfortunately, the image quality of webcams has not been anywhere near good enough to make nice looking time-lapse videos but this has changed over the last few years and is continuously improving. The results presented in this article are captured using my Logitech QuickCam Vision Pro 9000 – one of the greatest UVC cameras out there.
This weekend was dedicated to learning and experimenting with Gstreamer – an open source library and framework for constructing audio and video processing pipelines. Despite the weekend being spoiled by lots of bad luck (power outages, Internet down, etc.) I managed to beat the hell out of Murphy and get some work done!
My hidden agenda is of course finding a good audio/video library to accompany a software defined radio created using GNU Radio and the Universal Software Radio Peripheral (USRP), and to eventually be able to transmit real time high definition video over the air. While GNU Radio and the USRP can take care of everything related to software radio and RF, I am still looking for a good framework for flexible audio/video processing.