Cooking with Linux - Lights...Camera...Action!
I'm afraid it's true, François. The camera does not lie. That's what you look like when you are serving wine. Of course, mon ami, I have no intention of putting this little video on our restaurant's Web site. Why am I doing this? Ah, you have not yet looked at the feature for today's menu. Multimedia and entertainment is the ticket, mon ami, and you have to admit, this little video certainly is entertaining. Don't be upset, François, I have the ultimate respect for you. Besides, there's no time to fret, our guests will be here any moment. Ah, you see, they are already at the door.
Welcome, mes amis, to Chez Marcel! It's wonderful to see you all today here at the finest Linux restaurant on the planet, which also happens to be the home of one of the greatest wine cellars in the world. Please sit and make yourselves comfortable. François was just heading to the wine cellar now. The 2001 Santa Lucia Highlands Pinot Noir is drinking very nicely. It's a showy wine, bursting with hints of stardom—perfect for today's menu.
As you will notice, each workstation today is equipped with a small Webcam and microphone. The immediate idea is that we (or someone else) will wind up as the star of our little movie, but sometimes the software itself is the star. After all, many an application has shone on Chez Marcel's menu, non? And, this is where Karl Beckers' xvidcap comes into play. xvidcap is a great little tool for recording the action on your X desktop using a program called ffmpeg, which likely is already on your system. The result is an MPEG movie of your entire desktop or any portion thereof.
Why would you do such a thing, you might ask? Well, you can use this to create a training video to show others how to use an application or to show the world how good you are at playing your favorite first-person shooter. To get your copy of xvidcap, head on over to the official Web site (see the on-line Resources). The site offers both source and some binary packages, such as RPM or DEB. Should your particular distribution not be covered, building xvidcap from source is a simple extract and build five-step:
tar -xzvf xvidcap-1.1.3.tar.gz cd xvidcap-1.1.3 ./configure make su -c "make install"
The program name is either xvidcap or gvidcap. I say either because if you have the GTK2+ development libraries (version 2.2.1 or later), you get a second binary. Both work the same but, quite honestly, the GTK2+ interface looks and works better. If you don't have a recent GTK2+, you still may be able to get the interface by using one of the binary packages as opposed to source.
When you start either version of the program from the command line, you see a simple toolbar with a few buttons and a red rectangle floating below it. This is the capture window, and you can move it to cover whatever area you want to record. The default window, however, is fairly small. To change the area you want to record, click the crosshairs icon (second from the right on the toolbar), then click and drag the pointer to take in whatever area you want to include in your capture. The red rectangle will be resized. The toolbar contains buttons to record, stop, pause and so on. Pausing over the buttons will display tool tips. That's it, you are recording a movie of whatever transpires inside the red rectangle (Figure 1).
Some preference settings let you change the number of frames per second, the video codec and whether you want to capture the mouse pointer in the final video. Right-click on the frame button (first on the left) and select Preferences (Figure 2). After you've experimented for a while, type man xvidcap for details on running the program without the GUI. The added bonus is that you can capture audio as well, which is perfect if you are creating an instructional video.
One of the reasons I made a point of mentioning ffmpeg when introducing xvidcap is that it is an amazingly versatile little program and well worth getting to know. You can use ffmpeg to create your own movies with next to no expense. A cheap Webcam and, assuming you want sound, an equally cheap microphone are all you need (and ffmpeg, of course).
A few weeks ago, I was asked to create an introductory video for a book project. The quality wasn't expected to be exciting, because this was mostly a proof-of-concept thing and not meant to be the final product. Because I did not have a proper video camera, I had to improvise and thereby created what might well be the world's cheapest video recording studio (Figure 3). My setup was a cheap microphone and a cheap USB Webcam with a CPIA chip. Armed with my Linux system, I figured I was ready to go. The only question was “How?”
Using ffmpeg, I created my video clip, experimented with timing, frame rate and so on, until I had something that was getting pretty good. With the following command, I created an AVI format video clip at ten frames per second:
ffmpeg -vd /dev/video -ad /dev/sound/dsp -r 10 \ -s 352x288 video_test.avi
That's it. My video device input (indicated by the -vd option) is /dev/video and my sound, or audio, input was /dev/sound/dsp. That's the -ad option. Your own devices may be a little different of course. For instance, on another of my machines, the USB video device is /dev/video0. As it stands, the command continues to record until you run out of disk space. So, to limit a recording to ten seconds, I use the -t option:
ffmpeg -vd /dev/video -ad /dev/sound/dsp -r 10 \ -s 352x288 -t 10 video_test.avi
- Hacking a Safe with Bash
- Django Models and Migrations
- Secure Server Deployments in Hostile Territory, Part II
- The Controversy Behind Canonical's Intellectual Property Policy
- Huge Package Overhaul for Debian and Ubuntu
- Home Automation with Raspberry Pi
- Shashlik - a Tasty New Android Simulator
- Embed Linux in Monitoring and Control Systems
- KDE Reveals Plasma Mobile
- diff -u: What's New in Kernel Development