## Beginning to experiment with Avisynth - No clue what to do

This forum is for questions and discussion of all the aspects of handling your footage. If you have questions about capturing/ripping footage, AviSynth, or compression/encoding/converting, look here.

### Beginning to experiment with Avisynth - No clue what to do

Alright, so... I have no idea how to clean this up.

http://img34.imageshack.us/img34/2408/examplebo.jpg
http://img816.imageshack.us/img816/4835/example2m.jpg

I tried Deen("w2d",4,6,9,min=0.9) and GradFun2db(2) and although it helped, it made other problems (such as messing up other scenes after it) Should I split up the source into separate pieces and apply filters to them individually?

I'm sorry for asking for something that seems pretty simple. I'm hoping that once I find the answer to this basic step, the rest of this Avisynth business will be a breeze

bloppyblue

Joined: 22 Dec 2006
Status: Can't edit for crap. But I can try :/

### Re: Beginning to experiment with Avisynth - No clue what to do

So basically, you just want to filter that particular scene, but nothing else?
Check out applyrange():
Code: Select all
applyrange(100,200, "GradFun2db()", 2)
This will apply gradfun2db() with a value of 2 on frames 100 to 200 only... and leave the rest of the frames untouched.

Although applyrange is a little annoying to use if you have a lot of arguments like you've got for deen. I would actually suggest not using deen anyways in favor of fft3dgpu() or a cautious dfttest() in this case [I didn't test it].

An alternative would be to set some variables; split your video using trim(); apply your filters, and rejoin like so:
Code: Select all
video      = avisource("C:\path\to\your\video.avi")firstframe = 0startframe = 100endframe   = 200lastframe  = video.framecount()video.trim(firstframe, startframe-1 )++\video.trim(startframe, endframe     ).Deen("w2d",4,6,9,min=0.9).GradFun2db(2)++\video.trim(endframe+1, lastframe    )

Hope this helps

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Phantasmagoriat

Joined: 06 Feb 2006
Status: ☁SteamPunked≈☂

### Re: Beginning to experiment with Avisynth - No clue what to do

Beaten to it somewhat, but anyway...

A) Those Deen settings are way too high, especially for stuff produced over the last, decade, almost - and arguably stuff released over the past decade, barring some rather horrendously botched authoring jobs or discs produced from bad or inadequate masters, something most discs less than ~6 years old don't generally have a problem with... (unless it's Manga Entertainment we're talking about). A radius of 4 is practically never necessary, as 4 on any of the modes is tantamount overkill, putting aside that you'll be getting other posts pretty soon equating Deen use in general with tantamount overkill.

B) While you could do better to reduce the problem by lowering your Deen settings or using a different smoother, it is possible to isolate sections in videos by using Trim(). To use Trim effectively for what you want to do, however, you need to be comfortable using variables in your script. Like so:
Code: Select all
v1 = YourSourceLoaderHere()Trim(v1,0,199).YourFilteringChoicesA() ++ Trim(v1,200,399).YourFilteringChoicesB() ++ etc.

'v1' is the variable, although the name needn't actually be v1 - you could call it 'fuwafuwatime' for all AviSynth cares, although that would be rather cumbersome of a variable name to be lobbing around. What each instance of Trim is doing is loading 'v1', a.k.a. your source video, cutting out frames 0-199 or 200-399, and then applying some sort of filtering to them - the fact that AviSynth interprets periods between commands the same way it interprets having each command on a new line makes this possible. Also remember that it starts counting frames at 0, not 1, so if you wanted the first 200 frames you need 0,199 like I showed.

Obviously it requires some pre-planning to know what frame ranges you need. The ++ stitches the segments back together after you've applied filtering to them; in actuality, ++ is shorthand for AlignedSplice, which will maintain audio sync between segments. + is shorthand for UnalignedSplice, which doesn't take audio into account (and thus, + might preserve sync, or it might not; it depends on what you're feeding it).
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog

Qyot27
Surreptitious fluffy bunny

Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

### Re: Beginning to experiment with Avisynth - No clue what to do

For starters, don't EVER use deen for anything ever. Also use PNG for screenshots, otherwise it's hard to tell what is in the video and what is due to jpeg compression. My first suggestion for that would be get a better source, followed by ttempsmooth().gradfunkmirror(). I don't think they need tweaking. Also ignore everyone who says use applyrange. You're better off just trimming like Qyot writes, although I prefer a different syntax to what he wrote. You might also want to look into a program called YATTA, it writes avisynth for you based on where you tell it to apply filter ranges. It's magic and VERY powerful, like the oldspice guy or Yukarin.
Mister Hatt

Joined: 25 Dec 2007
Status: better than you

### Re: Beginning to experiment with Avisynth - No clue what to do

Mister Hatt wrote:Also ignore everyone who says use applyrange.
What's wrong with applyrange?

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Phantasmagoriat

Joined: 06 Feb 2006
Status: ☁SteamPunked≈☂

### Re: Beginning to experiment with Avisynth - No clue what to do

Phantasmagoriat wrote:
Mister Hatt wrote:Also ignore everyone who says use applyrange.
What's wrong with applyrange?

Bad memory management. Using "fancy" trimming instead of applyrange will make the script faster for the same result.

mirkosp
MODkip

Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: （」・ワ・）」（⊃・ワ・）⊃

### Re: Beginning to experiment with Avisynth - No clue what to do

Hmm...

Then I'll make my own function using trim()
Code: Select all
########### range() v1.0 by Phantasmagoriat #############function range(      \  clip     c      \, int     "f1"      \, int     "f2"         \, string  "filterchain"){filterchain = default( filterchain, """deblock().dfttest().blur(1.58)""" )# default is a "quick fix" for areas that are hard to cleanf = eval("c." + filterchain)c.trim(0,f1-1)++\f.trim(f1, f2)++\c.trim(f2+1,c.framecount())}

So if you want to apply something like ttempsmooth().gradfunkmirror() to only frames 100-200 you can go:
Code: Select all
range(100, 200, """ttempsmooth().gradfunkmirror()""")

and it won't have the annoying argument problem that applyrange() had, so you can put anything in between the triple quotes-- parameters, arguments, and all. Or if you find a few frames that are really difficult to clean, just go:
Code: Select all
range(100, 105)
by default, deblock().dfttest().blur(1.58) will be used as a "quick fix"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Phantasmagoriat

Joined: 06 Feb 2006
Status: ☁SteamPunked≈☂

### Re: Beginning to experiment with Avisynth - No clue what to do

Phantasmagoriat wrote:Hmm...

Then I'll make my own function using trim()
Code: Select all
########### range() v1.0 by Phantasmagoriat #############function range(      \  clip     c      \, int     "f1"      \, int     "f2"         \, string  "filterchain"){filterchain = default( filterchain, """deblock().dfttest().blur(1.58)""" )# default is a "quick fix" for areas that are hard to cleanf = eval("c." + filterchain)c.trim(0,f1-1)++\f.trim(f1, f2)++\c.trim(f2+1,c.framecount())}

So if you want to apply something like ttempsmooth().gradfunkmirror() to only frames 100-200 you can go:
Code: Select all
range(100, 200, """ttempsmooth().gradfunkmirror()""")

and it won't have the annoying argument problem that applyrange() had, so you can put anything in between the triple quotes-- parameters, arguments, and all. Or if you find a few frames that are really difficult to clean, just go:
Code: Select all
range(100, 105)
by default, deblock().dfttest().blur(1.58) will be used as a "quick fix"

Thanks bro, I had always been too lazy to write it on my own (although I'll change the "quickfix" bit on my end >_>).
Cheers.

mirkosp
MODkip

Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: （」・ワ・）」（⊃・ワ・）⊃

### Re: Beginning to experiment with Avisynth - No clue what to do

No problem
I've been meaning to do that for a while too.

the "quickfix" bit is just a last resort... I mean, what else can you do when a few frames look like crap?

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Phantasmagoriat

Joined: 06 Feb 2006
Status: ☁SteamPunked≈☂

### Re: Beginning to experiment with Avisynth - No clue what to do

Depends which frames and what kind of crap. Sometimes freezeframe, other times... yeah, nuking. But it's just that deblock().dfttest().blur(1.58) seems like some EXTREME nuking, I'd think that dfttest() on its own would suffice for most bad cases.

mirkosp
MODkip

Joined: 24 Apr 2006
Location: Gallarate (VA), Italy
Status: （」・ワ・）」（⊃・ワ・）⊃

### Re: Beginning to experiment with Avisynth - No clue what to do

True enough.
I guess when I nuke, I nuke HARD!

You know, I think I'll make a new thread for range() instead of hijacking this one
viewtopic.php?f=45&t=101949

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Phantasmagoriat

Joined: 06 Feb 2006
Status: ☁SteamPunked≈☂

### Re: Beginning to experiment with Avisynth - No clue what to do

Thanks for the responses guys, but there are just some things I want to get clear...
I'm more confused about what filters I should be using than how to separate what gets filtered... And almost all the answers were regarding trimming the clips and such... Sorry for not making that clear

So I tried to do ttempsmooth and I'm confused as to what I should put in for "pfclip" When I put in "null" an error window opens. When I close that error window, AvsP starts going haywire and more error windows pop up.
Error window says:
Code: Select all
Traceback (most recent call last):  File "AvsP.pyo", line 7123, in OnPaintVideoWindow  File "AvsP.pyo", line 9467, in PaintAVIFrame  File "pyavs.pyo", line 322, in DrawFrame  File "pyavs.pyo", line 306, in _GetFrame  File "avisynth.pyo", line 309, in GetPitchValueError: NULL pointer access

But for a thousand times or so.

Then I tried dfttest and it won't locate the libfftw3f-3.dll in the System32 folder (with PATH set... I read that in another thread) So I gave up on that.

So I started to mess around with it...
The original:

With
Deblock(quant=25, aOffset=0, bOffset=0, mmx=true, isse=true)

And then with
Deen("w3d",3,3,5)

But it STILL looks crappy. Holy crap, this is driving me insane!

I know somebody said NEVER to use Deen, but I don't know what alternative to go to!

bloppyblue

Joined: 22 Dec 2006
Status: Can't edit for crap. But I can try :/

### Re: Beginning to experiment with Avisynth - No clue what to do

Oh yeah, and is there anyway to avoid having things just flat out destroyed? That's gonna have to be dealt with range/trim/whatever, right?

Regard the black dress.
Before:

After:

Voila, it's gone.

Argh, I'm going insane!!

bloppyblue

Joined: 22 Dec 2006
Status: Can't edit for crap. But I can try :/

### Re: Beginning to experiment with Avisynth - No clue what to do

bloppyblue wrote:I'm more confused about what filters I should be using than how to separate what gets filtered... And almost all the answers were regarding trimming the clips and such... Sorry for not making that clear
don't mention it, we were probably getting OT anyways, that's why I made a new thread

So I tried to do ttempsmooth and I'm confused as to what I should put in for "pfclip" When I put in "null" an error window opens. When I close that error window, AvsP starts going haywire and more error windows pop up.
Error window says:
Code: Select all
Traceback (most recent call last):  File "AvsP.pyo", line 7123, in OnPaintVideoWindow  File "AvsP.pyo", line 9467, in PaintAVIFrame  File "pyavs.pyo", line 322, in DrawFrame  File "pyavs.pyo", line 306, in _GetFrame  File "avisynth.pyo", line 309, in GetPitchValueError: NULL pointer access

But for a thousand times or so.
did you try ttempsmooth() just by itself without any arguments? Do you even have TTempSmooth.dll in your avisynth plugins folder?

Then I tried dfttest and it won't locate the libfftw3f-3.dll in the System32 folder (with PATH set... I read that in another thread) So I gave up on that.
Did you check if you actually have libfftw3f-3.dll in your C:\Windows\System32 folder?

So I started to mess around with it...
[...]
But it STILL looks crappy. Holy crap, this is driving me insane!
It's not that that bad, some of it may even go away in the final stage when you compress your video... but still it looks like you'll need to experiment with temporal cleaning filters [like fft3dgpu(), ttempsmooth(), dfttest(), fluxsmoothst() etc...] and a gradient-fixer [gradfun2db(), gradfun2dbmod(), gradfunkmirror() etc...] I can't recommend much for temporal filters because they are... temporal. Thus require a sequence of frames to process [I suppose if you are really desperate, you could post a lossless video clip... ] But anyways, you'll definitely need a gradient-fixer. Higher values with gradfun2db show some good improvements at the expense of some haloing around edges, but if your temporal filters do a good job you won't need as high values for gradient fixing.

bloppyblue wrote:I know somebody said NEVER to use Deen, but I don't know what alternative to go to!
Yeah, Deen is generally not a good idea, but if it gives you the results you want, nobody is stopping you from using it. I would just combine it with something like range() so it doesn't get applied to your whole video... otherwise most of your video will look overfiltered. If you want alternatives, check out my last post in this thread:
viewtopic.php?f=45&t=101111

bloppyblue wrote:Oh yeah, and is there anyway to avoid having things just flat out destroyed? That's gonna have to be dealt with range/trim/whatever, right?
yup. Combine the filters that work the best with range(), and only certain frames of your video will be filtered. But I guess, the long and sort answer is you'll have to experiment.

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Phantasmagoriat

Joined: 06 Feb 2006
Status: ☁SteamPunked≈☂

### Re: Beginning to experiment with Avisynth - No clue what to do

To be completely honest here, monitor settings have a lot to do with how noticeable this is. I threw the before and after shots next to each other and jumped back and forth in Firefox, and I couldn't see the problem with the black dress. I had to crank my brightness values way up just to see it (and yeah, that's pretty nasty, but I'm not seeing why the smoother - any smoother - was even necessary in the first place).

K-ON! is a really, really recent source. There should be practically no reason to smooth it at all, aggressively or otherwise (especially depending on other factors like the resolution you'll be distributing at, as some resizing methods will mask imperfections when you downscale). And without the smoothing being there, the need for gradfun to clean up the banding the smoother may cause/exaggerate is even less necessary.

The key to AviSynth filtering is essentially less is more. If you can't identify the exact problem you want to fix, and then locate an adequate filter to do that job, just don't filter it. 'Filtering' in this case meaning things intended to do enhancement - smoothing, sharpening, Tweak or ColorYUV, etc.; frame manipulations like inverse telecine (IVTC) and resizing are a different story. Again, however, IVTC and resizing operations are used on an as-needed basis, not simply because it's possible to run them on any video you may come across. And if the filter seems to be doing too much, lower its strength. If you get to a point where even the lowest strength attempt is too much, find another filter and test its results.

So my primary suggestion here is to bone up on what, if any, actual issues to fix are there first, not to basically throw paint at a canvas and hope you get the The Disintegration of the Persistence of Memory.
My profile on MyAnimeList | Quasistatic Regret: yeah, yeah, I finally got a blog

Qyot27
Surreptitious fluffy bunny

Joined: 30 Aug 2002
Location: St. Pete, FL
Status: Creepin' between the bullfrogs

Next