The non-magic of Avisynth - Tutorial

Jan 07, 2008 10:31

So I promised doing this for giandujakiss and hope it can be useful for others as well.

First of all I’m not an Avisynth expert, there might be simpler, better and more straight forward ways to get these masks and changes done. This is my method. It works for me, but feel free to change stuff or tell me what you would do differently.

Second there are more tech oriented guides out there and I believe also several updates to the software versions offered as AMVapp. I would recommend to read AMVapp intro carefully to get the necessary software and understand how it basically works. It might be a long read, but it will pay off even if it probably doesn’t make much sense at first, you will get there. There is also a lot of information gathered at Avisynth.org and for the newest developments and filters it’s always good to take a look at doom9 avisynth forums.

Third I use avisynth in Premiere 6.5 because I don’t need to reencode footage this way and can use my original vob-, mkv- and avi-files. It might not work in other applications or upgrades. I know that there is a way to make it work in Vegas, but this is something you need to look into for yourself. I will not go into how to prepare your DVD footage for Premiere or get rid of the watermark in downloaded files. If there is any interest I will do a short one on the watermarks, but otherwise you will find all the info in the above links.

Because this tutorial is about the result you get from your editing software, everybody should be able to try it.

So you edited a video, it’s finished and ready to be published, although it looks a bit boring and you want to enhance it. What I do now is exporting my video from Premiere as Huffyuv v2.1.1 - CCESP Patch v0.2.5 - Huffy is a fast, lossless codec that gives you your footage 1:1 without any loss in quality as an output. The file you get is around 1,5 GB - 2,5 GB for a three minute music vid. It’s huge, but also top-quality or as good as your input was. I do this for years, previously only to get a good input for my various web encoders, but now we will play with this specific file in avisynth.

First get AvsP - It is an avisynth text editor with fancy stuff like sidebars for easy manipulation and an excellent preview function. This preview function will be your friend soon enough and F5 was never more interesting. So you drag and drop your avi-file there and get something like that:

AVISource("C:\Your.avi")

If you preview you see that it is your file 1:1. But we will do some tweaking soon, so you better change the colourspace before you offend your filter.

AVISource("C:\Your.avi")
ConvertToYUY2

If you preview nothing interesting has happened at least not for your eye, so lets change that.

AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")

Things got brighter. We made an overlay of the original source.

There are countless way to achieve brighter footage in avisynth - level, contrast, brightness -, but I figured I introduce this overlay method early on. Anyone familiar with graphic programs like Photoshop or even the overlay function in Premiere will be familiar with the modes shown in the sidebar next to your preview. Changing the opacity and modes for fun and you get the principle behind an overlay. So moving on:

AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")

I overlayed this bmp-picture here. It’s a colour gradient mask I made in PS and thought would look good on top. Of course you can go wild here, even use textures you would normally use in PS or general go over the top. I just wanted to fade the edges a bit and make the emphasis on the middle.
I vid with PAL DVDs, so my framrate is 25 frames per second or fps=25, change these to your own framerate. The start and end just does exactly that. So you could in theory make different overlays on different parts of your vid.

Now let me introduce you to a denoiser I use dfttest. You need to install it in your windows library, so we need to load the plug-in from there. Avisynth recognises plug-ins and filters in its own library, so you usually don’t need to use LoadPlugin, if you stuff your filters into the plugin folder of Avisynth. But like I said, this denoiser needs to be in the windows library so we do:

LoadPlugin("C:\Windows\dfttest.dll")
AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")
dfttest(sigma=1.00)

Everything looks smoother now, play a bit around with stigma for example sigma=1.5 and you get a good idea what it does. Denoiser makes things smoother, you only have to be careful so you don’t lose details. So hopefully we get rid of unnecessary noise, which will help you make small file sizes for web download. Like always playing around with stuff is your friend in Avisynth, especially when it is so easy as in AvsP, so do it. Because we now come to the part, where I love to do it. I introduce proudly the tweak function. Hah!

LoadPlugin("C:\Windows\dfttest.dll")
AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")
dfttest(sigma=1.0)
tweak(sat=1.15, bright=-5, cont=1.25, hue=0, coring=false)

So again with the sidebar on your preview - tweak has a lot of additional functions like hue and stuff, but if you click on tweak you see the one you have chosen. Now play wildly with the bars and you will understand what each of these does. Or you can gain from your graphic knowledge. Saturation makes or breaks the colour in your vid. Brightness makes is darker or you guessed correctly brighter. Contrast does exactly that. Hue is included as example - 0 does nothing, but again you can play around. Why I added coring escapes me at the moment, so I guess it is not so important, usually it is true, if you don’t add the function like I did.

Tweak is your friend, play with it. It’s fun.

LoadPlugin("C:\Windows\dfttest.dll")
AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")
dfttest(sigma=1.0)
tweak(sat=1.15, bright=-5, cont=1.25, hue=0, coring=false)
temporalcleaner()

With temporalcleaner() we add another denoiser, the standard one. You should have it already in your plugin folder. As mentioned previously denoiser make things smoother.

LoadPlugin("C:\Windows\dfttest.dll")
AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")
dfttest(sigma=1.0)
tweak(sat=1.15, bright=-5, cont=1.25, hue=0, coring=false)
temporalcleaner()
MSharpen(strength=45)

We want some sharpness back without the noise, so we do that with MSharpen, strength indicates what it says so change it a bit so see what it does.

LoadPlugin("C:\Windows\dfttest.dll")
AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")
dfttest(sigma=1.0)
tweak(sat=1.15, bright=-5, cont=1.25, hue=0, coring=false)
temporalcleaner()
MSharpen(strength=45)
Crop(0, 0, -2, -2)
LanczosResize(720,400)

The next step is easily done - go to Video -> Crop editor.

With DVDs you usually have a small black bar on the sides or on top or bottom of your footage. Most noticeable is the lack of it if you zoom into it a scene and it suddenly disappears. We want to get rid off it. So go to a frame especially bright and do exactly that. (The crop function is awesome if you edit movies and the footage is 2,40:1 and you have the black bars on top and bottom, so do this step ahead if you are doing a movie vid and your editor accepts avs-files.)

Then resize it to your original size or anything you want it to be with LanczosResize(720,400)

LoadPlugin("C:\Windows\dfttest.dll")
AVISource("C:\Your.avi")
ConvertToYUY2
clip1 = AVISource("C:\Your.avi")
Overlay(clip1, opacity=0.25, mode="add")
farbe1 = ImageReader("C:\Maske.bmp", start=1, end=4358, fps=25)
Overlay(farbe1, opacity=0.1, mode="hardlight")
dfttest(sigma=1.0)
tweak(sat=1.15, bright=-5, cont=1.25, hue=0, coring=false)
temporalcleaner()
MSharpen(strength=45)
Crop(0, 0, -2, -2)
LanczosResize(720,400)
water = ImageReader("C:\signature.jpg", start=1, end=4358, fps=25)
Overlay(water, opacity=0.6, mode="add")

Now I only added my watermark with this two lines. Again you should be by now familiar with the overlay function.

We are now finished with the script, but what to do with it? If you installed the AMVapp you get VirtualDubMod. Open the program go File -> open video file via Avisynth. Now go to Video -> Compression and select Huffy again, press okay. Go to File -> Save as… Select a appreciate name - something like yourfile-filter.avi. Don’t overwrite your original avi-file.

With all the filters it can take some time for VirtualDubMod to process your file, usually it takes half an hour for me, but that solely depends on your processor. Once you have the Huffy put it through your web encoder like AutoGK or DivX Converter. I use the later with the setting to Home Theater and nothing changed from the original settings and get files around 30 MBs for a three minute vid. So drag & drop again and convert.

Like I said I’m not an expert, but if you have questions I try my best to answer them and I hope this was helpful for Avisynth novices and people who already worked with the program.

tutorial, vid_stuff

Previous post Next post
Up