video encoding&cleaning


Encoding with Media Tools
MPEG4 versions
DivX5 , encoding hints

Smart Bitrate Control (SBC)   

Interlaced MPEG4
Field order issues
Procedures for camcorder footage


Consider this page as information; If you want wmv, you may want to use Windows Movie Maker. Some use DIVX or XVID to save disk space, also for HDTV. I would nowadays prefer MPEG2 or X.264, however. 

Encoding with Media Tools

If you don't mind using Microsoft's propriertary file formats, you can use Windows Media Tools for encoding, online and offline. Media Tools 4 beta insisted to encode in real time, so only half frame size was possible. The 4.1 final allows for offline encoding in full format. For basic setup, see the PC-Videorecorder page.
Media Tools 7 (no more compatible with Windows 95) come with a new set of codecs that are not accessible by software relying on Video for Windows. The V1 (ISO) and V7 (about identical to V3) codecs are based on DirectX. V2 has gone !!
I therefore really recommend to get the old tools as long as they are there for download.

File encoding is also possible with Media Tools 7 but setup is awfully complicated. MS WindowsMedia8 encoder is much better for this purpose.

Media Tools 7 and Media Player 7 can coexist with the 4.1/6.4 versions quite well. If Media Player 7 grabs too many file formats, just start 6.4 and use its settings to reassign formats.
Media Tools 7 may place their links to the same startup menu group where those of Media Tools 4.1 reside, so move the 4.1 links away before installing 7. It might also be a good idea to make a backup copy of the Windows Media Tools directory. This should be about all to regard for a co-installation.


MPEG4 versions

Microsoft published 3 codec types, V1, V2 and V3. V1 is supposed to be ISO compliant (MS really claims that only for the V1 DirectShow codec that comes with Media Tools 7) but not very good. V2 is OK. The quality advantage of V3 is more crispness and a better accuracy of interframe calculations: V2 tends to retain faint 'shadows' of previous frames that don't disappear before the next keyframe. You can see this with objects moving before a blue sky, for example. The effect can be minimized if you select a short keyframe interval. V3 does not need this, therefore it can be used with longer intervals.
The V1 and V7 of Media Tools 7 are DirectShow codecs and no good for nothing outside Media Tools so far. V2 is no longer contained, only playback is still supported. So if you need the old V1/2/3 codecs, get MediaTools 4.1 while they last (see links page).
The new WindowsMedia8 codecs are far better and have a command line encoder that lets you avoid the complicated setup of MediaTools7. More on the
WindowsMedia8 page.

The fact that Microsoft had removed AVI support from V3 since MediaTools 4 final, and the fact that many users are concerned about the future usability of MPEG4V2 as well, easily explains why an underground 'standard' emerged around a modified Microsoft MPEG4V3 codec, that works with AVI file format. One more reason is that Microsoft's asf file format tends to stutter at playback and that there is almost no software to edit it (they even forced Avery Lee to remove asf support from VirtualDub).
"DivX;-)" (not to be confused with the failed pay-per-view standard) installs separately without Media Tools, which also explains its popularity. The legal status of that is questionable, although the MS MPEG4 codecs have always been free for Windows users and many still have V3 versions that work with avi files.
Using the "DivX;-)" codec for commercial purposes can not be recommended. Using it personally if you already are a legitimate user of MS codecs could be OK or not depending on your local copyright laws, because this is just the same MS codec with a few bytes changed and the question is if these changes are allowed.
Meanwhile several people started projects to make a new codec free of Microsoft's copyrights. Also Microsoft's new Video8/Audio8 codecs were released and will deliver strong competition.



Gej, who made DivX;-), also started his own development ProjectMayo (open source) and then the commercial

Meanwhile, DivX5 has been released.
It's even better; I could encode a 110 min full PAL movie to one CD without even any filtering (for a pretty clean TV recording), and it looks excellent. Needs 1200 MHz and up to watch smoothly. Another improvement: The second encoding pass now runs twice as fast.
I did not apply any settings except qpel and bidirectional encoding, and setting the bitrate of course.
Use the Div4 option of my bitrate calculator, then you'll get very accurate results at least for 2-pass encoding.
The silly 'activation' is still present in DivX5pro (if every piece of software I've registered would use activation, I would definitely have thrown my computer out through the closed window several times, given the number of system updates I do !). You can also use the ad supported version (safe in terms of stability, however it spys on your surfing habits).
Result from long and extensive test with DivX 5.02: It's simply the best. However I couldn't find any major effect (despite of large CPU load) for the Qpel and GMC features in the Pro codec version, and the bidirectional (B-frames) feature has its quirks: It really saves 20% file size or improves detail, but I noticed (seldom but reproducible) single frames with artifacts in any encoding I did so far. The other problem: I can't get it to play reliably smooth on my Matrox Dualhead TV output, even if CPU load was only 50% and even not with 'real time' priority set for Media Player. The improvement of detail is there but not so obvious that I would accept the problems. Maybe this doesn't happen to all users, so please do your own tests if you feel that you need the most extreme compression. Be aware however that the first announcements of hardware DivX decoders also did not contain B-frames as a supported feature.
Two pass encoding however is a must: The second pass now runs almost twice as fast as pass 1, and the gain from only about 50% more encoding time is definitely worth the while.

Conclusion: Very little reason to use more that the standard DivX5.02 encoder, but any reason to use just that one, in two pass mode of course.

More info in the forums at and ProjectMayo.
Also see the official statement from the developers.
Very interesting the claim that DivX4/5 and OpenDivX are fully ISO-MPEG4 compliant !

Encoding example (DivX4) here.

The betas had a lot of problems and were slow, but version 4.22 has completely catched up to DivX;-)3.x plus nandub, even a little better in some aspects, because some artifacts like speckles left behind moving objects and restlessness in pastel colors are reduced, and CPU load at playback is 10-20% less so it runs more fluent.
Last but not least, i
t's also fully legal, not a modification of MS codecs but a proprietary development.
I can put a 2 hr 2.23:1 widescreen movie on one CD and the result is very convincing. Same for a 16:9 movie of 90 min. With 2-pass encoding, quality here gets even better.
I also tried some full size PAL takes from camcorder with extreme movements, and the codec compresses and plays them perfectly. Bit rates in that case became more like MPEG2 of course, especially when I left it interlaced, which also worked perfectly well.
All with more speed than DivX;-)3.x. (704x576 interlaced rendered at 5 fps on a Celeron @ 864, setting 'slowest'. Absolutely outstanding indeed).

An example encoding process for DivX4.12:

Captured 85 min from TV, with PIC MJPEG codec set to 20/20, 4:1:1, one field.
Cut and encoded in VirtualDub in one action with the following filters:
- Cropped to 720x432 (null transform filter)
- Temporal Smoother at 3 (almost perfect noise reduction)
- Xsharpen at 63,47 (mild sharpening effect)
- DivX4.12 with all default parameters, slowest, bitrate 1020 kbps.
2-pass encoding took 2x 10 hrs on a Celeron@874 (the only drawback), sound passed through in this case and later processed to mp3/128kbps but this could also happen with a codec in pass 2.
The result came out really excellent. Hard to distinguish from the original, except for the typical expense for high compression: Fine low contrast detail is often blurred a bit. Hardly visible in the running movie but apparent when comparing frames.

I've selected an especially bad example to illustrate this:

The first frame is the original, denoised and optimal for encoding.

This is the DivX4 encoding with parameters as described above. Everything is OK except for the low contrast background, which is considerably blurred. In the running movie, this is not so apparent because there's no direct comparison and also the action distracts the eye.
This kind of degradations may sometimes be reduced by specifying a lower maximum quantizer in the codec's settings.

Here an example with very fast, flash-like movement.
First the original PIC MJPEG capture:

Then the filtering result:

And the DivX4.12 encoding at 1020 kbps, 2-pass VBR:

The artifacts are invisible in the actual scene because it's so fast, and we also have extracted the image with VirtualDub, hence without any post filtering, so we see more artifacts anyway. From the actual viewing, violent motion and also strong motion together with calm low contrast areas, really the foes of older codecs, came out almost impeccable. These examples can also hardly be judged from still frames.

Now after We've seen the maybe worst pictures from an entire movie, which really doesn't do the codec justice, one that looks more like the real impression:

With the last DivX version, bitrate is also closely controlled, especially with 2-pass. However it needs to enter a larger number compared to DivX;-)3.x or MS MPEG4. So I added a Div4 option (also for DivX5) to my bitrate calculator that gives you 1.024 times the Div3 bitrate. Note that bitrate may still deviate if you specify something outside the reasonable range.

DivX5 adds many more encoding feature like B-frames, and promises even better quality. Also playback smoothness has been improved, and DivX3.x movies are played back without problems.

Encoding to true MPEG4 streams, as well as MP4 audio, is still in testing stage, but as DivX-chips have already been licensed, there's a good chance that we will be able to play back DivX encoded movies in future stand-alone DVD players.

For TV recordings, a filter set like this might be optimal:

With Smart Deinterlacer set like this:

(assumed we have a PIC MJPEG source with advanced settings to 20/20 and 4:1:1, e.g. approx. Q=16, or better).

The result from this is usually both cleaner and crisper than the original TV transmission. Temporal cleaner would be less CPU intense than Temporal Smoother but at strong settings it makes traces. Temporal smoother is also good against wandering moiré and stripes.

If you have to resize, use the resize filter (obviously), with precise bicubic at '1.0'. This best preserves crispness.
If your video has black edges, these could also steal some bits of bandwith from the encoder. Cropping may result in odd frame sizes with equal problems.
Trick: Try just cropping the borders off, then resizing to a correct frame size (multiples of 8) with Precise Bicubic/1.0. It's astonishing how hard it is to see any ill side effects from this, especially when resizing just by a few lines. (The filter is intelligent enough to have zero effect if you resize 1:1, BTW).

For further encoding, I'd recommend DivX 4.12, 2-pass, like this:

Note that most is default. 1350 is good for 720x576 resolution. For 16:9 films, 1000 or less delivers high quality.
To run both passes unattended, use VirtualDub's job control:
1)Set codec to first pass.
2)Do save avi then abort after a few seconds.
3)Save avi again but with the deferred box checked and answer 'overwrite file' with yes.
4)Set codec to second pass.
5)exactly as 3)
Now open VirtualDub's Job Control and press Start.

In order to process in background, set VirtualDub's priority to 'even lower'. You may set this as default in 'Options'.


DivX4 can also play back DivX;)3.x files, apparently more fluent than the original. Sound sync issues seem to have gone with 4.11. Picture quality is almost identical but not 100%. Under Win95/98, the decoder refuses to take over anyway. You may remove that option easily by reinstalling without it. If you have 3.11, I'd still recommend this.

The 4.12 codec does not affect others, the installation so far didn't cause any conflicts with my numerous media applications. The Player ('Playa') that comes with it was greatly improved with version 4.12. However with some DivX;-)3.x files it will not work, for no obvious reasons. What's really amazing is the Playa's desktop mode: The video replaces your wallpaper !

Conclusion: DivX4 finally keeps up to the promise and really has the potential to become the 'mp3 of video', not only for it's quality but also because it's free for personal use, plays DivX;-)3 content and is fully MPEG4 compliant (at least claimed so).

BTW, using MPEG4 for VCD frame size and the same high data rate is not a good idea. In that case, MPEG1 is the better choice as it is a widespread standard that also plays on desktop players and the quality is as least as good, if encoded with a good software like TMPGenc (which delivers about the best results you can get for MPEG1 and MPEG2 and is free to use in trial mode). The VCD version of the above MPEG4 example is on the VCD page.

For bitrates over 2500 kbps, MPEG2 made with TMPGenc is the better choice compared to MPEG4.
Only the new DivX4 can keep up in this case, but not as well when interlacing is required.

MPEG4 including DivX4 however requires more CPU power than MPEG1 or MPEG2 for decoding clips of the same quality level. 500 MHz or better recommended for full frame size. VCD (MPEG1) and half size MPEG4 play on much smaller CPUs. On a P133, VCD is the only format that works.

MPEG4 is generally the better choice for higher compression settings, e.g. bitrates below 2500 for full frame size and below 1200 for half format.

BTW sometimes there may be jerky effects with MS MPEG4 when panning. The reason in these cases may be Media Player and/or CPU power, most likely.
If playback is staggering, you should check out which resolution, color depth and which level of hardware acceleration works best on your system.
Very fast movements can make MS MPEG4 or DivX;-)3 deliver jerky results in any case. It's a weak point of the codec.
Smart bitrate control with nandub can overcome this.
DivX4 does not have the problem. It plays smooth under almost any circumstances, even at nearly 100% CPU load. The downside is that it may get out of audio sync if the CPU can't keep up.


Based on many experiments I have written a bitrate calculator that also lets you optimize the frame size, according to the desired quality. See Links.


Smart Bitrate Control

It is possible to merge MPEG4s with different bitrates, if all other parameters are equivalent.

Manual Method:
Just encode a video with a 'sufficent' bitrate and then again with a bitrate that is good even for the most difficult parts. Review the low bitrate result with VirtualDub and determine which parts are bad. Then use the cutting feature to divide both videos into pieces and the 'append video segment' feature to merge pieces from both files.
Remark: You can only cut successfully by starting at a keyframe and stopping directly before the next keyframe.
You may open two instances of VirtualDub parallel to save low or high bitrate parts alternately. Give the avi pieces continuous numbers so VirtualDub can open them all automatically as video segments afterwards.
A program that makes this much easier is "ProjectDivX". It allows for very easy manual optimization. Together with the latest version of "DivX;-)3.20", which has scene detection and inserts a keyframe at every scene start, this works quite well.
ProjectDivX also works with DivX4 files, BTW. If you want to resize or clip only part of a mixed format video, this tool might still be very useful.

Remark: Some tools (even "ProjectDivX") tell you to use the high and low motion "DivX;-)" codecs for the alternate sources, which is bad advice. The 'advantages' of the high motion codec are about zero, more a placebo effect than a reality. The trick for best motion quality (least blockiness) is to set 100% 'crispness', with all varieties of MS MPEG4.

Automated SBC (nandub)

An even much better encoding method is implemented in
nandub (available at
Bitrate is adjusted frame by frame, and additional output control triggers re-encoding if the feared freezings occur. The program can even resort to key frames only to force the encoder to do its work. Only problem: There are many controls (most of them have little effect BTW), and targeting the exact output bit rate desired can be cumbersome.
Nandub also works with MS MPEG4V2, so it's possible to stay all on the legal side and produce excellent videos for distribution (however, DivX;-)3.x has better quality).
Nandub is based on the source code of VirtualDub but is intended for encoding only.
Meanwhile DivX4 is a real alternative, it's easier to use, about as good, and fully on the legal side. With its 2-pass encoding, you really don't have to bother much and get excellent results.

Practical results with nandub: I could encode a 53 min. documentary in 704x576 on one CD, with excellent crispness. This source had many difficult scenes and resisted any attempt to encode with manual bitrate control.
It was still necessary to prepare the source with Smart Deinterlacer, Temporal Cleaner and Smart Smoother (lowest setting).
Playing this CD from a CD drive however was hardly possible without some occasional stuttering: The peak bit rates are so high that it's better to copy it to a harddisk before viewing.
I'll redo this one with DivX4 when I have time and I'm already sure it will be a good deal better.

An simple example for movie encoding:
Source was 16:9, PAL, 84 minutes.
Used nandub to crop to 704 and then resize to 704x400 (only the resize filter with the crop option on, simple bicubic resize).
SBC settings:
Set bitrate to 970 avg., 250 min (has hardly any effect),
Compression Levels : Set only main DRF level to 11 max
and keyframes quality to 3 min. Nothing else.
Encoding: With nandub, use 1 pass if you don't have a very fast CPU. Since 2-pass is mainly necessary to tune to the desired filesize and nandub doesn't keep that well either, 1-pass may be quite as good if you experiment the size yourself and give it enough variability for bit rates. Encoding part of the video will give enough data to adjust it. Adjust by max DRF level only, anything else will hardly have any effect.
Needless to say that the video came out excellent, better than a manual 2-bitrate SBC with only 60 min on the CD.
Here as well, DivX4 with 2-pass encoding will make the whole hassle obsolete.

Another experiment: Same settings but bitrate 600/200 fit a 2.35:1 movie (704x320) of 134 min to one CD. The trailer (>5 min) was encoded with half bitrate. In this case, bilinear resizing was used. Bicubic was only marginally crisper in this case but let the size of this video really explode (possibly due to hardly visible noise). Very respectable quality.
I already redid this one when DivX 4.01 came out and it was good but not as crisp as the nandub version. DivX 4.11 has become much better, crisper and with less artifacts, so use this for new encodings.

Note that playback quality always depends on the system used. Weaker CPUs usually have less power for playback optimization. With DivX4 and high quality videos, always use only 1 step of postprocessing. Ramming the slider to the right will only blur the video. Leaving it all left will allow hard block margins. Moving it 1 step to the right will soften just this and leave all else clean.


Interlaced MPEG4

The TV output of a Matrox G400/450/550 can handle interlaced video. I accidentally compressed interlaced material to MPEG4 without the deinterlacer and - surprise - the MPEG4 output played correctly w. both fields. Of course the fields are still combined in the same frame, but the video output has no choice but to send first the odd, then the even lines to the TV (no TV can accept it other than that). The surprise was that the two compression steps - first capturing to MJPEG (1 field 704x576), then compressing to MPEG4, did not produce much crosstalk between the adjacent lines, so that the interlaced output mode still looked good (even w. relatively low quality settings, BTW). DivX4, by the way, works even better with interlaced stuff. It produces relatively large files with this but plays smoothly, much better than the older codecs.
For noisy Sources, Temporal Cleaner can be applied without problems.
Of course this 'interlaced' MPEG4 still shows the jagged edges on computer monitors, but for viewing on TV, I can recommend it.

Example video (1MB zipped file). Only useful if you have a TV output.

There is a site with a very good explanation about what is interlacing. It's German but you can get a web translation at Lycos. Or you read the online tutorial at

Another very interesting thing you can do about Interlacing BTW is to double the frame rate. See the TMPGenc section about it.

Field order issues

I sometimes observed that PAL TV stations swapped fields even between frames (!!). There is a VirtualDub filter called PAL-Deinterlacer to correct this. Use the VirtualDub Link below.
If you have problems with cartoons and other stuff that has been converted from NTSC to PAL, the 'Telecide' Filter can work wonders.

Procedures for camcorder footage

Especially analog recordings have relatively much noise and line jitter which is not so obvious on a TV but becomes a real problem with deinterlacing. DV footage is by far less difficult, at least when taken at bright light.
For analog captures, it's recommendable to use Smart Smoother, R3 w. interlaced option (or Temporal Cleaner w. same option if CPU power is scarce, or as well Temporal Smoother depending on the source), then Smart Deinterlacer (only if your target is viewing on computer monitors) with these options.
If you can play back Hi8 material on a Digital8 camera, you will also get the better capture quality and can use the same procedures as for digital tape. In this case you also shouldn't bother about getting an analog video card. It's pretty useless. Just opt for a DV and a TV card.



This is amateur camcorder material. Hi8 tape played with a Digital8 Camcorder and captured via IEEE1394 interface. Filters: VirtualDub Smart Smoother R3 interlaced, then Smart Deinterlacer (settings here) to have complete comparability with the TMPGenc example. Encoding done w. VirtualDub, DivX4.11 2-pass ('slowest'), bitrate 2500.
4 seconds, file size 2 MB.
BTW, the little stairs at the edges of some bright white objects are an effect of the camera. I could also have used a cleaner source but such average amateur material is more difficult to deinterlace and to encode so it's a better test for the process.

I think the example shows that Smart Deinterlacer has reached a very mature state. Smart Smoother (same for Temporal Cleaner or Temporal Smoother) removes the noise from the analog tape without blurring anything. For DV footage the prefiltering wouldn't always be necessary. The MPEG4 data rate could be lowered to fit 60 min on one CD, because longer films seldom have as much motion as this example.

The last scene however is extremely difficult and would normally stutter with MS MPEG4 or Divx;-)3.11 without using nandub. It would also be difficult with MS Media8.
With DivX4 as well as
TMPGenc (MPEG2) it works.
Procedure for MPEG2:
Use TMPGenc with the DVD template but change max. bitrate to 3000 and quality to 35%, or use 2-pass with average bitrate at 2500...3000. Some templates on the TMPGenc page.
If you do not want to use VirtualDub as preprocessor, use TMPGenc's adaptive deinterlacing filter.
Not even every TV output handles interlacing correctly, so you might want to deinterlace first. Tsunami has filters for this. See the
TMPGenc page for procedures and an example of the same footage.

Hint: If you have Video8 or Hi8 tapes, play them on a Digital8 camcorder. It will play back in better quality than on the analog device and the output will also be time base stabilized and much easier to capture. Even better if you capture the digital output directly by the DV (IEEE1394) interface.
You may also use many Digital8 camcorders as direct analog to digital converters to improve and capture signals from VHS video recorders or cameras. In Europe, you have to enable the analog and digital inputs by changing the firmware settings of the camera. Several video vendors offer that service. Go get such a Digital8 camera, it's an unbeatable value for the money.


Copyright (C) 1998-2011; all rights reserved. All materials in these pages are presented for scientific evaluation of video technologies only. They may not be copied from here and used for entertainment or commercial activities of any kind.
We do not have any relation to and do not take any responsibility for any software and links mentioned on this site. This website does not contain any illegal software for download. If we, at all, take up any 3rd party software here, it's with the explicit permission of the author(s) and regarding all possible licensing and copyright issues, as to our best knowledge. All external download links go to the legal providers of the software concerned, as to our best knowledge.
Any trademarks mentioned here are the property of their owners. To our knowledge no trademark or patent infringement exists in these documents; any such infringement would be purely unintentional.
If you have any questions or objections about materials posted here, please
e-mail us immediately.
You may use the information presented herein at your own risk and responsibility only. We do also not guarantee the correctness of any information on this site or others and do not encourage or recommend any use of it.
One further remark: These pages are covering only some aspects of PC video and are not intended to be a complete overview or an introduction for beginners.