MPEG-2 to MPEG-4 tutorial
1.About this tutorial
This tutorial has been broken down into 6 chapters which explain the process of converting an MPEG-1 or MPEG-2 DVD file into an MPEG-4 video wrapped in AVI file, which is often incorrectly called "DivX" (see the DivX chapter for more info). There are several projects available online which allow you to convert DVD's to MPEG-4 AVI, using tools such as the popular MEncoder. The difference between Avidemux and these other projects is that Avidemux allows you to edit the file before encoding it, and to do a visual check of what you are doing.
Understanding MPEG file types
Supported MPEG Formats
Video Only |
Video & Audio |
m1v |
mpg |
m2v |
vob |
x |
vdr (mpegTs) |
- m1v means "MPEG-1 Video", i.e. a file which only contains a so called elementary video stream, without any audio.
- m2v means "MPEG-2 Video".
- mpg is a program stream containing the multiplexed video and audio streams.
- vob is a DVD systems stream which contains video, audio and additional information, it is a also a program stream.
- vdr is a transport stream containing video and audio(s). It is supported but without sync correction.
Getting a usable VOB file using MPlayer
Code listing 1.1 |
mplayer dvd://1 -dumpstream |
This will create a file in your working directory called stream.dump. This is an Avidemux compatible VOB file in MPEG format with various audio streams.
Loading and Indexing your MPEG File
Load this stream.dump file into Avidemux by either clicking the "Open" folder icon in the toolbar, or going File->Open....
You will now be presented with a dialog box asking if you would like to index the MPEG, say yes.
The next dialog is the default audio track selection, that looks like this
.
You will be able to change audio track later on if you selected the wrong default audio track. If there is less than two audio tracks, you won't be asked.
Once the indexing is over, the index will be automatically loaded.
Note: Avidemux does not read MPEG streams. It has been designed to read an MPEG stream index. An MPEG stream index is a plain text file containing a description of the MPEG and the location of frames throughout the stream. This file allows Avidemux to random seek and stay accurate. Said otherwise, without the index, Avidemux cannot handle MPEG files.
2.Editing features and options
NSTC versus Film
Some DVDs are coded as 23.976 aka FILM (most movies actually). Some others are coded as 29.96 (NSTC), soap for example. In the first case, the DVD player does an operation to convert it on the fly to NSTC format (telecine). So the MPEG header always says 29.96 as it will always be the final format.
Avidemux uses mpeg2dec to decode MPEG streams (with a little patch). mpeg2dec does not do the telecine on FILM movies (and that's better that way).
It means that Avidemux cannot tell the difference between FILM and NSTC.
So if the MPEG looks progressive (not interlaced) and obvious desync appears (and gets worse and worse), use Video->Frame Rate and set it to 23.976.
For PAL MPEG, there is no problem, it is always 25 fps.
Cropping
Resizing
If you'd like to resize the video to something smaller, bring back up the video filter list. To correctly resize a video, it is very important to take the aspect ratio into account. The aspect ratio is the shape of a pixel. On a PC it is mostly square (1:1), however, on a DVD it could be 4:3 or 16:9. So, select the input aspect ratio (16:9 is the most common for DVD) and target aspect ratio (1:1 for AVI, 4:3 or 16:9 for DVD). Then select the resizing method, bilinear is generally good enough for downsizing. You probably will want to check the 16 round up to be sure the final width and height are multiples of 16. Then move the slider until you reach the desired width.
More video filters
Depending on the source, you may want to add more filters (subtitling, denoiser, deinterlacer...). See video filters for more information on available filters. One of the best I've found is the "MPlayer denoise3d" filter. This filter smooths the image a bit. Default values on it are fine.
At this point, the video is ready for any editing you may wish to do. For information on cutting please see the Cutting Guide.
3.Configuring the audio encoder
First be sure to have selected the right audio track. Your ears might be handy for that. In case the wrong one has been selected, use Audio->Main Audio Track to select the right one. You may also choose an external file as audio track.
Audio codec
Do i want additional processing?
In some cases, doing some audio processing may be desirable. For example, doing volume normalization or downsampling.
Press the Configure button to select the audio processing you want.
4.Configuring the encoder
Codec
Time to select a codec. My two preferred are XviD and libavcodec, with a preference to XviD4. You can use Windows based tutorials for XviD as the options are the same. For libavcodec, have a look in MPlayer documentation.
Do i want to use it?
If you are not really concerned with the output size, you know what you are doing and you can skip this chapter.
In most cases, you want to reach a specific total size. Click the Calculator button to make that dialog appear:
Select your final wrapper, in our case AVI and the size you want, then press Apply. The average bitrate for video and average bit per pixel will be updated. The video codec will also be setup to use dual pass and the correct target size for video will be set.
When happy with the result, just press Apply, then Close.
5.Saving
Now select the output format using the pulldown menu. Most probably AVI.
Avidemux will do pass 1 then switch to pass2 (including audio).
|