This article is more than 1 year old

Getting Started with Avisynth

Turn your PC into a video powerhouse

That should have cheered you up a bit about Avisynth, so perhaps you're now in the mood to go back to the script and give it another read. Actually, it's not that opaque. In line one we have some kind of input file called Clip1.d2v to which we apply a function called MPEG2Source and then assign the result to an arbitrary variable we call video. Something very similar goes on in line two, where the result is assigned to audio.

Line three dubs the audio onto the video. Line four trims the result, removing the first 29 frames, keeping all the remaining frames up to and including frame 162052, and junking any frames after that. And so on...

This is all very wonderful, you might be saying, but no darn use to me if it involves having to write a script like that. So here's where I drop my mask of advanced geekery and tell you that I didn't actually write that script. Nor did anybody else. It was written for me by a particularly neat piece of software called AvsP. AvsP is a text editor that understands Avisynth a lot better than I do. And it can show me, frame by frame, what it's doing - it has its own built-in mini-Moviola, if you like. And like Avisynth, it's free.

If you've tried to remove ads from TV movies in the past, you'll probably have used the straight cut. I started with a proprietary package called VideoReDo, which makes an excellent job of this. But you quickly discover that while straight cuts can get rid of the ads, they usually fail to disguise the fact that something's been removed. Often you'll get a jump in the sound, a glitch on the video, or just an awkward sharp transition. The good news is that - for our present purposes at least - you can nearly always fix this by substituting a long, short or medium dissolve. VideoReDo can't do dissolves. Final Cut, of course, can, although it seems to go out of its way to make this very awkward. Avisynth takes dissolves in its stride.

Assembling the Tools

Perhaps the most challenging part of the Avisynth process is setting up the software in the first place. Windows XP 32-bit is the environment of choice - although all this can be made to work with Vista and Windows 7 - and I recommend creating a directory under Program Files called Video Tools.

Install the following there, each in its own individual sub-directory:

Software Current Version Source Location
Avisynth 2.5.8 http://sourceforge.net/project/showfiles.php?group_id=57023
DGMPGDec 1.5.5 http://neuron2.net/dgmpgdec/dgmpgdec.html
NicAudio 2.0.2 http://nicaudio.codeplex.com/
AvsP 2.0.2 http://avisynth.org/qwerpoi/
MPC-HC 1.2.908.0 http://sourceforge.net/project/showfiles.php?group_id=170561
WinFF Installer 1.0.4 http://winff.org/html/downloads.html
XViD 1.2.2 http://www.koepi.info/xvid.html
VirtualDub 1.8.8 http://virtualdub.sourceforge.net/

The last two rows are optional, although well worth installing. XViD is a system-wide codec, but you won't need it if you're using WinFF to encode and Media Player Classic-Home Cinema (MPC-HC) to play back; these come with their own encoders/decoders. VirtualDub will become indispensible if you want to venture into the art of logo removal, but you can get through the basics without it.

Next page:
GOPs and Frames

Compressed video is stored in a series of 'groups of pictures' (GOPs). The first frame of each GOP, the 'key frame', contains enough compressed data for the decoder to recreate the whole frame. But the data for subsequent frames - and there may be as many as 300 of them in a single GOP - contains only delta information, a description of the extent to which these following frames differ from the key frame or - and there's very fancy maths at work here - from their immediate neighbour frames.

Simple editing software can cut compressed video only on the key frame. Any attempt to cut inside the GOP will destroy subsequent frames and also probably ruin the sound sync. More sophisticated video editing software, like VideoReDo, will re-encode that particular GOP, allowing you to cut on any frame. This is called 'frame-accurate' editing.

Avisynth is a 'frameserver', decoding every GOP on demand as the editing software calls it up. Effectively, our editing is being carried out on a stream of fully detailed frames, so we don't have to worry about GOPs. As it's also a scriptable frameserver we're not confined to straight cuts - we've seen from the example above that Avisynth can equally easily do dissolves (or virtually anything else) around the cut point.

More about

TIP US OFF

Send us news


Other stories you might like