Updated: December 4, 2008
This is the second of the three articles on how to use and manipulate multimedia formats: Flash, video and audio. In the first article, we have concentrated on Flash files: how to download them from websites, how to convert between formats (e.g. flv to .avi), how to extract music from Flash movies and online streams, how to convert various formats to .swf files, insert meta data into Flash video, and several more cool tricks.
In this article, we will talk about video files: splitting and joining them, changing encoding and compression, fixing bitrate discrepancies in audio and video, and other tasks. In the last article, we will manipulate audio files: convert between different music formats, like .mp3, .ogg, .wav, and others, mix sounds, compose custom pieces by splicing segments from different tracks, and more.
On top of all that, we will also talk about useful multimedia programs that can help us in our common daily tasks, namely audio and video recording software. Best of all, everything I'm going to show is free. Last but not the least, we will see examples for both Windows and Linux. So let us begin.
Table of contents:
- Manipulate video files
- Record video
Let's say you have a video file of some sort. Let's say you want to burn it to a CD, but it's too big. You need to split it into several parts. Similarly, you have lots of these segments, which you would want to join into a single file. Or you have a movie that stutters. Or perhaps the sound is not quite synchronized with the picture, making it all look like a bad foreign movie. Or maybe you want to make the movie smaller, encode it in a friendlier format that takes less space.
All these are very common tasks that just about anyone using computers faces. In this tutorial, we'll learn how to very simply, easily overcome these issues. Let's start with splitting files into smaller bits.
A nice, cross-platform choice for both Windows and Linux users is the HJSplit program. It's an utterly simple and friendly utility. In Linux, it usually does not come included in most repositories, however it is included in Dreamlinux, a distro with an exceptional multimedia support. If you're interested to learn more, you can read my article Dreamlinux - Review & Tutorial. The numerous multimedia features are extensively covered on page 4.
Windows users have another choice: VirtualDub. This is one of my favorite media processing programs. I use it quite often for all sorts of tasks. I will demonstrate many of the tasks we'll do here in VirtualDub.
Just like HJSplit, it allows you to cut your movies into shorter pieces. It also allows you to grab segments out of the middle of your movie clip and save them as individual pieces, without begin restricted to the beginning or the end of the file. To mark the desired range, just use the arrow-like markers:
Then, save the cropped section by going to File > Save segmented AVI...:
Now, please note this is only part of the job. We have not yet talked about the output format at all! VirtualDub will take the segment and process it using set video and audio processing mode and compression. We have not yet covered these, so please wait just a few moments, we'll get there.
Similarly, HJSplit and VirtualDub will do the job. The task is much simpler with HJSplit. You merely need to find the split parts and combine them.
VirtualDub is a little tricker in this regard, but nothing special. The first step is to open the two or more files that you wish to manipulate. Let's say you have two parts of a movie, part 1 and part 2. Naturally, you want to append part 2 to the end of part 1.
So, what you need to do is open part 1 and then go to File > Append AVI segment ... VirtualDub will ask you which file you wish to append. Choose part 2. Then, save the combined track (File > Save as AVI...). If you want to mix, this is one way of doing it - simply append the same piece over and over again.
Let's say you want to change the encoding your movie has. Or you want to change the audio format. VirtualDub is your man (woman) for the job. You can easily shrink (or inflate) files by changing the compression used for audio or video (or both). The available choices will depend on the codecs you have installed and used on your system. Here's how you can do it. First, open a file. Then, click Video in the menu. Choose Full processing mode.
Your other options are to sacrifice some quality and recompress the file using Fast or Normal recompress. Direct stream copy will simply play the video without doing anything. This is useful if you want to recompress only the audio, for example, without touching the video, saving time and effort.
Once you choose either one of the options except Direct stream copy, the grayed out options at the top of the menu will become available. For now, we're interested in Frame Rate and Compression.
Here, you can manipulate the output of your files. For example, after taking the game movies recorded in DOSBox for my 1942: Pacific Air War article, I made them significantly smaller by reprocessing them in XviD format instead of the original ZMBV. This made them smaller approx. 4.5 times.
Similarly, you can increase or decrease the frame rate.
This is a MUST-DO step before any manipulation including any sort of processing of video (or audio), otherwise, the default will be no compression, which will result in huge output files (raw data).
Therefore, before you split or join files using VirtualDub, make sure you set the right compression - or use Direct stream copy. Similarly, you can process audio, in much the same fashion. Choose the mode of work, choose the compression and off you go.
In Linux, you can use ffmpeg to do the job. We have mentioned this extremely useful utility in the first article. For instance, to transcode an .avi movie into a .vcd file:
Or to force the output file to use the frame rate of 24 FPS:
But you may want GUI. So, here's another utility for Linux worth mentioning - Avidemux. Note: it will also work on Windows! Like VirtualDub, it allows you to change video and audio encoding, change the output format, and in general, manipulate loaded files any which way you see fit.
In a way, this section covers three issues all at once. For starters, we had the conversion between different formats. Furthermore, we used different compressions for both video and audio and we changed the frame rate as needed.
You may load a file for processing, let's say in VirtualDub, when you get to see the following warning:
So, if we try to manipulate this file, we will get skewed audio up to 42 seconds out of sync with the video. This is definitely not something we want. Therefore, we will process the audio, just as suggested - and even use the recommended bitrate (if possible). Similarly, if you have a file with stuttering audio, you may want to load into one of the programs mentioned above and reprocess it.
You may want to create your own movies by recording your computer in action - a presentation, a tutorial, maybe even a game. For example, my article 1942: Pacific Air War features a pair of movies. Likewise, my Gutsy Gibbon review also has a pair of movies, demonstrating the power and beauty of Compiz. Some of the tips, tricks and how-tos mentioned both in this tutorial and the first part have already been reviewed in these two articles.
This is an excellent tool. I have used it to create my Ubuntu 7.10 Gutsy Gibbon Compiz demonstrations. It can create a range of output formats, including Flash. Quite a few Linux distributions have this fine utility included in the repositories.
Again, this mighty little monster is up to the task. ffmpeg can capture the screen. Even if you have multiple monitors, you can use it to record only specific display. Browsing through the documentation is highly advisable, for lots of examples to some of the most common tasks. BTW, ffmpeg can also capture audio devices ...
This is not a video recording software, per se. It is an MS-DOS emulator, a great one at that, allowing you to play your favorite childhood oldies on modern computers with modern operating systems. It also can record movies of applications and games running inside it.
For example, my 1942: Pacific Air War movies come from within the DOSBox. It will record .avi movies encoded in the ZMBV format, which you can view in VideoLAN (VLC) without the need for any extra codecs. To create a movie, all you have to do is: Ctrl + Alt + F5 to start/stop recording.
On Windows, both VideoLAN (VLC) and VirtualDub can be used to record movies. We have already reviewed these two programs in both the first article and here. Additionally, VirtualDub can be significantly enhanced with plugins. These plugins include support for AC-3, FLAC, FLV, and other file types. You can find the plugins below:
We have done quite a lot actually. We split and joined video files using VirtualDub and HJSplit. Then, we changed the compression, frame rate and the output format of our files using VirtualDub and ffmpeg. Another useful tool for the task is Avidemux, which will run on both Windows and Linux. Lastly, we fixed out-of-sync audio in VirtualDub. For dessert, we reviewed the task of recording videos on our desktop.
As you can see, working with video is quite simple. Whether you're using Windows or Linux, you'll get the job done quickly and efficiently. You may not even have to use the command line (ffmpeg), although it is a fast and powerful tool and you should not be afraid to embrace it. In the next part, we'll tackle audio.
P.S. In the fourth part of this saga (undeclared, but it will come!), I'll show you how to permanently add subtitles to movies. And maybe some other stuff, too :) P.S.S. One day, I will also show you how to create Flash animations and slideshows, so stay tuned.
For the time being, have fun!