Problem w/artifacts using Thalen DeShaker in Virtualdub

1. With RGB to YV12 conversion, in addition to the accuracy losses from YUV to RGB conversion, you lose color resolution. Say you start with a 720x480 RGB source. Each pixel has a red, blue, and green value. In essence you have a 720x480 red image, a 720x480 green image, and a 720x480 blue image. When you convert that to YV12 you get a 720x480 Y (grayscale) image, and 360x240 U and V images (color information). This can be seen quite clearly (or should I say blurrily?) if you convert small color RGB text on a colored background to YV12.

Regarding the accuracy issue it can be very simply demonstrated by this: In a computer image there are 256 shades of gray. R=G=B=0 is black, R=G=B=255 is full white, and 254 shades in between. But in YUV video Y=16 is defined as black and Y=235 is defined as full white. So there are only 220 usable shades of gray in YUV space. To properly convert 256 RGB shades of gray to YUV you have to reduce the number of shades to 220. So obviously, there must be some duplicates.

When people talk about lossless integer colorspace conversion what they usually mean is that you don't get successively greater errors if you convert back and forth repeatedly. So on the very first conversion from RGB to YUV you will get losses but if you turn around and convert that back to RGB and then back to YUV and back to RGB, etc you don't accrue more and more errors. I believe AviSynth has implemented this level of losslessness.

Of course, you can also work with more bits of precision (ie, 10 bit, 12 bit, 16 bit per channel) to reduce the scale of losses (ie, 1 part in 65536 is much less of an error than 1 part in 256). Or you can work in floating point to get more intermediate precision while filtering. Many audio editors can work in floating point. It's not common in video because of the much greater memory and CPU requirements.
2. Originally Posted by jagabo
Yes. But some are actually scripts and rely on several other filters. You'll have to read the docs to find out what filters you need to download and install.
Which docs and where do I find them?
3. Originally Posted by poisondeathray
This is just an example of one way of doing it. There are many many other methods, filters, settings you could choose. Please don't think this is the only way you can do it. There are many more simpler workflows, and some even more convoluted
I'll go with these as a starting point.
4. Originally Posted by poisondeathray
Code:
```AVISource("test.avi")
ConvertToYV12(interlaced=true)
TempGaussMC_Beta1(sharp=0)
Dehalo_Alpha(darkstr=0.9,brightstr=0.9)
MCTemporalDenoise(settings="high")```
Looking for these filters, I find several such as Dehalo_Alpha as a text file

So do I copy this text and save it as an avsi file in the Avisynth plugins folder?

Further on this page http://avisynth.org/mediawiki/DeHalo_alpha it talks about "required filters." Does this mean these filters are also needed to use the other?

Then I used deshaker , exported a lossless lagarith 60p file, and re-interlaced it

Code:
```AVISource("deshaken.avi")
AssumeBFF()
SeparateFields()
SelectEvery(4,0,3)
Weave()```
Are these commands filters or just commands Avisynth recognizes?

So I imported this .avs script into vdub to use deshaker
When I go into Vdub, I don't see .avs as an option under 'Run Script". How do these text commands need to be saved for Vdub to recognize them?

Thanks
5. Originally Posted by brassplyer
So do I copy this text and save it as an avsi file in the Avisynth plugins folder?
Yes, and by saving it as an .avsi (as opposed to a regular .avs) it's supposed to load automatically. If it doesn't, change the extension to .avs and use a 'LoadPlugin' line at the top of the script.
Further on this page http://avisynth.org/mediawiki/DeHalo_alpha it talks about "required filters." Does this mean these filters are also needed to use the other?
Yes, those will be the filters required (the DLLs) to be loaded before DeHalo_Alpha will work. It depends on those other filters to help remove the edge enhancement. Ordinarily, sticking those filters into the plugins folder will allow them to load automatically. Again though, if they don't and you get an error message when trying to run the script, use a 'LoadPlugin' line.
Are these commands filters or just commands Avisynth recognizes?
The 4 commands below the AVISource line are built-in commands. You need nothing more than AviSynth being installed to use those 4.
When I go into Vdub, I don't see .avs as an option under 'Run Script". How do these text commands need to be saved for Vdub to recognize them?
You write your script in a text file renamed with an .avs extension. For example, you might have a Movie.avs, inside of which is the complete script. Then you open it as you would any video - File->Open Video or drag-and-drop. If you have problems show us the complete script you're using and give us the complete error message.
6. Originally Posted by manono
Yes, and by saving it as an .avsi (as opposed to a regular .avs) it's supposed to load automatically. If it doesn't, change the extension to .avs and use a 'LoadPlugin' line at the top of the script.`
LoadPlugin is for DLLs. For .avs files, you use 'Import'.
7. For example:

Code:
```import("C:\Program Files\AviSynth 2.5\plugins\WhatEver.avs")

You may find AVSP useful for writing scripts.
8. Originally Posted by Gavino
LoadPlugin is for DLLs. For .avs files, you use 'Import'.
Oh yeah. Thanks for the correction.
9. Originally Posted by Soopafresh
Get yourself a Hague MMC Stabilizer (steadicam) device for \$120 and you'll have more stable shots to begin with. You'll definitely reduce the times you'll need to use Deshaker.

http://www.vimeo.com/8800412

http://vimeo.com/804381
Great tip!
I looked at some youtube videos and it seems to make a big difference.
Some people build similar stabilizers in the garage but for \$120 it seems like I could buy one (not too expensive).

One trick is to use a tripod and hold it in your hand at the center of gravity (or just use it as a tripod if you don't need to walk around when filming).
10. Originally Posted by ronnylov
I looked at some youtube videos and it seems to make a big difference.
Yes, but most of the examples I've seen at Youtube really exagerate how bad handheld footage is.

Originally Posted by ronnylov
Some people build similar stabilizers in the garage but for \$120 it seems like I could buy one (not too expensive).
I've seen some instructions with a parts list that runs \$5 or \$10 from Home Depot. I don't think I have a link to it anymore though.
11. Originally Posted by ronnylov
Some people build similar stabilizers in the garage but for \$120 it seems like I could buy one (not too expensive).
I've seen some instructions with a parts list that runs \$5 or \$10 from Home Depot. I don't think I have a link to it anymore though.
.nod This looks like it would be fairly easy to home fabricate.

Unfortunately what it won't do is allow you to travel back in time.
12. Originally Posted by brassplyer
Unfortunately what it won't do is allow you to travel back in time.
I've seen a design for that with \$25 in Radio Shack parts. I'll post the link later...

13. Finding that even getting to the point of using these AviSynth scripts is something of a chore.

Looking for example at the page for MCTemporalDenoise

http://avisynth.org/mediawiki/MCTemporalDenoise

There's a long list of other "required" filters, many have their own "required" filters. At least one - DeBlock doesn't seem to be available anywhere - anywhere I find a reference to the page for the .zip file it brings to some other link about web servers, others required looking under crates in back alleys to locate. Not to mention wading through geek-speak documentation and learning curve with each one.

So at what point do you stop running around the rat maze chasing down "required" filters and get down to actually using the app?
14. Originally Posted by brassplyer
So at what point do you stop running around the rat maze chasing down "required" filters and get down to actually using the app?
When you've got all the filters you need?

You can try writing a simple script using MCTemporalDenoise and open it in a media player or VirtualDub. If a filter is missing you should get an error message indicating what's missing.

http://avisynth.org.ru/mvtools/deblock.html
15. LOL wait until you see how slow each stage is...then you can complain. Most of the filters are single threaded or poorly multithreaded, so you will have lots of idle CPU...

If you thought deshaker was bad, TempGaussMC is waaay slower, and MCTemporalDenoise on those settings is super.duper slow as well. All heavy denoisers are very slow, as are all high quality motion compensated filters

Not to discourage you from exploring these filters - I mentioned this earlier - but you might find something like neat video easier to use for the denoising part
16. Originally Posted by poisondeathray
LOL wait until you see how slow each stage is...then you can complain. Most of the filters are single threaded or poorly multithreaded, so you will have lots of idle CPU...

If you thought deshaker was bad, TempGaussMC is waaay slower, and MCTemporalDenoise on those settings is super.duper slow as well. All heavy denoisers are very slow, as are all high quality motion compensated filters

Not to discourage you from exploring these filters - I mentioned this earlier - but you might find something like neat video easier to use for the denoising part
I've got this much time into it, I'd like to at least mess with it some. But will likely check out the other as well.

On something like this LSFmod - should the entire text be included in the avsi file or just the portion from the "function" command? Does avisynth ignore lines with ### in front?

http://latoninf.free.fr/d9/LM/LSFmod.v1.9.avsi

Also what does the purple text in the upper left on all these Avisynth filter pages identify?

For example

http://avisynth.org/mediawiki/MCTemporalDenoise

Thanks
17. Originally Posted by brassplyer
On something like this LSFmod - should the entire text be included in the avsi file or just the portion from the "function" command? Does avisynth ignore lines with ### in front?

http://latoninf.free.fr/d9/LM/LSFmod.v1.9.avsi
Yes, # means "commenting out" , and it does nothing. It would be like REM statments in Basic programming language

If you have it as an .avsi file, everything should be included

Also what does the purple text in the upper left on all these Avisynth filter pages identify?
Those are the commands or switches for each function when you go and actually use it. If you don't specify anything, default values are used. MCTD has defined preset settings, if you look at the avsi, there is a chart for "strengths" (e.g. low, medium, high), with each setting having a value correlating to that preset.

You picked a bad one to begin exploring/learning with, because MCTD includes about 20 different filters
18. Originally Posted by poisondeathray
Those are the commands or switches for each function when you go and actually use it. You picked a bad one to start exploring, because MCTD includes about 20 different filters
The reason I 'picked" it was because it's included in the script you suggested.

*Oliver Hardy slow burn look*
19. Actually the same chart for the strength presets is reprinted in the wiki if you scroll down

http://avisynth.org/mediawiki/MCTemporalDenoise

The reason I 'picked" it was because it's included in the script you suggested.
If you noticed, I just used a simple preset, instead of fine tuning each parameter. I just used settings="high" ; when you could get better results customizing each parameter for your source
20. I see unzipping the DeBlock zip file creates 15 files. What do I do with them? None of the .txt files seems to clarify this.
21. Just put deblock.dll (and deblock.htm if you want the docs) in your AviSynth plugins folder. Most of the rest is the source code and Visual C project files.
22. Well this is interesting, masktools produces 2 dll files

and

Removegrain produces 12 .dll's

Now what...?
23. 25 for AviSynth 2.5.x, 26 for AviSynth 2.6.x.

RemoveGrain() has several version because they are optimized for different CPUs. Use the one for your CPU.
24. Originally Posted by jagabo
25 for AviSynth 2.5.x, 26 for AviSynth 2.6.x.

RemoveGrain() has several version because they are optimized for different CPUs. Use the one for your CPU.
Not clear to me this is what's going on. Here's a screenshot of the files in question.

25. You guys gonna leave me hanging here?

Since I got no response to the above I just dumped all the above .dll's into the plugins forlder.

When I attempt to run this script

AVISource("test.avi")
ConvertToYV12(interlaced=true)
TempGaussMC_Beta1(sharp=0)
Dehalo_Alpha(darkstr=0.9,brightstr=0.9)
MCTemporalDenoise(settings="high")

I get the error "there is no function named MVAnalyse"
TempGaussMC_beta1.avsi, line 161
26. You're missing a pre-requisite, I think it's MVTools

The pre-requisites are listed on the wiki and the documentation
http://avisynth.org/mediawiki/TempGaussMC

You may have to search for some (they might not be hotlinked), just use google "avisynth mvtools" and its the 1st hit
http://avisynth.org.ru/mvtools/mvtools.html

There are 2 branches of mvtools, 1, and 2, but they can both co-exist in the plugins directory (mvtools.dll, mvtools2.dll) . Some filters rely on one instead of the other, I forget which one TGMC relies on
27. Originally Posted by poisondeathray
You're missing a pre-requisite, I think it's MVTools

The pre-requisites are listed on the wiki and the documentation
http://avisynth.org/mediawiki/TempGaussMC

You may have to search for some (they might not be hotlinked), just use google "avisynth mvtools" and its the 1st hit
http://avisynth.org.ru/mvtools/mvtools.html

There are 2 branches of mvtools, 1, and 2, but they can both co-exist in the plugins directory (mvtools.dll, mvtools2.dll) . Some filters rely on one instead of the other, I forget which one TGMC relies on
Thanks, apparently I had one and not the other. I'm making progress, now it's telling me I'm missing "m4" related to DeHalo_alpha.

If it helps, this is what my plugins folder looks like currently
28. What's the full error message? I haven't seen that one "m4" before

Do you have the required filters?
http://avisynth.org/mediawiki/DeHalo_alpha

29. Originally Posted by poisondeathray
What's the full error message? I haven't seen that one "m4" before
Script error:There is no function named "m4"
(DeHalo_alpha.avsi, line 20)

Do you have the required filters?
http://avisynth.org/mediawiki/DeHalo_alpha