Cooking with Linux - Lights...Camera...Action!
The resulting clip, which I called video_test.avi, can be played with Xine, Kmplayer, MPlayer or whatever video player you prefer.
Well, mes amis, my foray into video production on the cheap was a success, or so I thought. When I sent the video clip for approval, I was asked whether they could have it in MPG format instead. Rather than redoing what obviously was a great work of cinematography, I converted it using the following command:
ffmpeg -i video_test.avi video_test.mpg
As versatile as ffmpeg is, you certainly should spend a few minutes looking at the man page. I promise you'll discover a lot of really cool uses for it.
For those of you who already own a digital video camera, recording high-quality video is not a problem. The challenge is to get the video on your hard disk for editing, compressing and eventually burning to disk for sending to friends and family. I have a Sony Handycam. It comes with a USB port, but it also has a much faster means of getting the video transferred through a high-performance serial bus or, as most people know it, a FireWire port. The real techies out there refer to it as an IEEE1394 port. Your computer also needs to have such a port (or card) in order to transfer the information, but the performance of the IEEE1394 port truly is worth the investment.
To manipulate the resulting video in a friendly way, however, you need to get your hands on a video editor like Arne Schirmacher's Kino (see Resources). The dvgrab program, also available from the Kino Web site, is built-in to Kino so you don't need a separate copy. You see, mes amis, like xvidcap, Kino uses a few command-line tools under the pretty interface. One of those tools is our old friend ffmpeg.
These days, Arne has some great developers working on the project, and they have put together a rather nice and easy-to-use video editor for Linux. See the feature article on page XX. The beauty of Kino is that you can use it to extract and edit video directly from your IEEE1394-compatible video camera. If you have such a device, which can be connected with a FireWire cable, Kino even lets you control the device through the application. Before I continue on, let me step back and say something about the IEEE1394 support. Any recent Linux distribution should have IEEE1394 support included (through loadable kernel modules), but on my test system, the drivers weren't loaded automatically. No problem—I loaded them manually:
modprobe ohci1394 modprobe raw1394 chmod 666 /dev/raw1394
Getting your digital video across the IEEE1394 cable and onto your computer can be done easily from the command line with dvgrab. After all, that's what Kino does to capture video. Although you can type dvgrab and start capturing, the best way to do this is by using the -i option, meaning interactive. You then can control the camera and capture using simple single key presses.
dvgrab -i Going interactive. Press '?' for help. q=quit, p=play, c=capture, Esc=stop, h=reverse, j=backward scan, k=pause, l=forward scan, a=rewind, z=fast forward, 0-9=trickplay, <space>=play/pause Capture Started
We become accustomed to working with graphical interfaces, but this is a lot easier and nicer to use than it sounds. The resulting video file on your system is called dbgrab-XXX.avi by default, the XXX being a three-digit extension.
Kino's interface is clean and easy to navigate (Figure 4). To the right of the main window, tabs indicate the various functions, from capturing to editing to exporting the finished product. The Edit tab is where most of the work happens (after the Capture, of course). This is where you cut or join scenes, or even insert additional files in to your video project. The Timeline tab breaks up the current scene (and video clip) into multiple frames, so you can jump to any part of the video without having to play the whole thing.
An FX tab lets you add various special effects to your videos. These include things like reverse video, sepia tones, mirror and kaleidescope effects and so on. Audio effects include fade in, fade out and silence.
Once you start truly enjoying your digital video camera, you are going to record more than a few minutes of tape. The reason I mention this is that when you are capturing output from your digital camera with Kino, a number of large files will be created, each about 820MB in size and each sequential for the duration of the video. Those mega-files aren't what you want your final product to be, however. That's what the Export tab is all about. Various options are available here (in a group of sub-tabs) including exporting only the audio tracks to WAV files. I also like the fact that I can export stills of individual frames. The option I tend to use the most, however, is DV pipe, and this is where ffmpeg makes an encore appearance.
After all the editing, cutting and pasting is done, I export my finished product using ffmpeg to either video CD AVI files or DVD format. The resulting files (for example, VCD AVI format) are much smaller and much more manageable. One hour of digital video takes up about 9GB of disk space. The exported video, however, fits nicely on a single 700MB CD-ROM.
As you can see mes amis, your Linux system provides some great tools to make you, or your software, a star. Speaking of which, it seems as though closing time has arrived already and judging by the wine-induced smiles on some of your faces, we have the opportunity to capture some memorable video. I jest, of course. François, do be so kind as to refill our guests' glasses one more time. Perhaps what we should capture for posterity is our parting toast. Until next time, mes amis, let us all drink to one another's health. A votre santé Bon appétit!
Resources for this article: www.linuxjournal.com/article/7808.
Marcel Gagné (firstname.lastname@example.org) lives in Mississauga, Ontario. He is the author of the all new Moving to the Linux Business Desktop (ISBN 0-131-42192-1), his third book from Addison-Wesley. In real life, he is president of Salmar Consulting Inc., a systems integration and network consulting firm. He is also a pilot, writes science fiction and fantasy, and folds a mean origami T-Rex.
Free DevOps eBooks, Videos, and more!
Regardless of where you are in your DevOps process, Linux Journal can help!
We offer here the DEFINITIVE DevOps for Dummies, a mobile Application Development Primer, and advice & help from the expert sources like:
- Linux Journal