Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd September 2017, 21:18   #1201  |  Link
Ben_Nicholls
Registered User
 
Join Date: Aug 2017
Location: N/A
Posts: 12
Quote:
Originally Posted by Khanattila View Post
KNLMeansCL(d=0), but the results are different...
Thanks
Ben_Nicholls is offline   Reply With Quote
Old 1st October 2017, 10:51   #1202  |  Link
tuanden0
Registered User
 
Join Date: Oct 2016
Posts: 111
I tried to use KNLMeansCL to denoise all luma and chroma but I get this error and the screen preview is black
Quote:
knlm.KNLMeansCL: fatal error!
My test script:
Quote:
clip = core.lsmas.LWLibavSource(r"E:\Download\testsc.mkv", format="YUV420P8")
clip = core.std.AssumeFPS(clip, fpsnum=24000, fpsden=1001)
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="YUV")
clip.set_output()
tuanden0 is offline   Reply With Quote
Old 1st October 2017, 11:31   #1203  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Quote:
Originally Posted by tuanden0 View Post
I tried to use KNLMeansCL to denoise all luma and chroma but I get this error and the screen preview is black

My test script:
"YUV" requires 4:4:4, aka no chroma subsampling.

Code:
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="Y") 
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="UV")
or

Code:
#convert to rgb
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="RGB") 
#convert to YUV again
__________________
github.com
Khanattila is offline   Reply With Quote
Old 1st October 2017, 14:05   #1204  |  Link
tuanden0
Registered User
 
Join Date: Oct 2016
Posts: 111
Quote:
Originally Posted by Khanattila View Post
"YUV" requires 4:4:4, aka no chroma subsampling.

Code:
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="Y") 
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="UV")
or

Code:
#convert to rgb
clip = core.knlm.KNLMeansCL(clip, h=0.4, channels="RGB") 
#convert to YUV again
It's work,
tuanden0 is offline   Reply With Quote
Old 6th October 2017, 19:05   #1205  |  Link
SaurusX
Registered User
 
Join Date: Feb 2017
Posts: 134
Can someone give me a primer as to what various settings of D and A result in? Such as what effect is to be expected, say, when D=1 and A=3, D=2 and A=1, etc? Maybe something like "X type of noise responds best with Y settings". It could be too broad of a question, but since this is such a time-expensive filter I'm looking for the best bang for the buck.

Currently I've settled on using knlmeanscl(D=1, A=3, h=??, S=1) for almost everything. I can push the D up to 2, but that increases encoding time on my GTX750 Ti by 40%. Also, on my system pushing up the D parameter can cause encoding errrors when combined with too many other temporal filters (I feel like I mention that a lot).
SaurusX is offline   Reply With Quote
Old 7th October 2017, 02:55   #1206  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by SaurusX View Post
Can someone give me a primer as to what various settings of D and A result in? Such as what effect is to be expected, say, when D=1 and A=3, D=2 and A=1, etc? Maybe something like "X type of noise responds best with Y settings". It could be too broad of a question, but since this is such a time-expensive filter I'm looking for the best bang for the buck.

Currently I've settled on using knlmeanscl(D=1, A=3, h=??, S=1) for almost everything. I can push the D up to 2, but that increases encoding time on my GTX750 Ti by 40%. Also, on my system pushing up the D parameter can cause encoding errrors when combined with too many other temporal filters (I feel like I mention that a lot).
Filter description here
https://github.com/Khanattila/KNLMea...er-description

In short, D and A are for temporal size and spatial size. For temporal, unless you have some crazy dancing grain, D=2 (5 frames) should be enough for your needs, I just use D=1.

For A, S and H you'll have to tweak it according to your source. First bump H (strength) high enough to a point where it removes all noises or where it stopped removing more noise. Then work on A and S one at a time to remove noise that H haven't. At the same time gradually slide down H without introducing more noise.

A is the speed killer of the filter, on my GTX 650 ti boost, setting A from 1 to 5 had my speed dropped from 36fps to 2.97fps on a 1440x1080 clip...

Code:
clip = core.knlm.KNLMeansCL(clip, d=1, a=5, s=4, h=8)
I really want to know how the newer graphic cards do with a higher A value, because 3fps is just way too slow to me.
lansing is offline   Reply With Quote
Old 13th October 2017, 23:28   #1207  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
Quote:
Originally Posted by lansing View Post
A is the speed killer of the filter, on my GTX 650 ti boost, setting A from 1 to 5 had my speed dropped from 36fps to 2.97fps on a 1440x1080 clip...

Code:
clip = core.knlm.KNLMeansCL(clip, d=1, a=5, s=4, h=8)
I really want to know how the newer graphic cards do with a higher A value, because 3fps is just way too slow to me.
RX 480 ~8.5 fps
__________________
github.com
Khanattila is offline   Reply With Quote
Old 14th October 2017, 06:29   #1208  |  Link
edcrfv94
Registered User
 
Join Date: Apr 2015
Posts: 84
Quote:
Originally Posted by lansing View Post
Filter description here
https://github.com/Khanattila/KNLMea...er-description

In short, D and A are for temporal size and spatial size. For temporal, unless you have some crazy dancing grain, D=2 (5 frames) should be enough for your needs, I just use D=1.

For A, S and H you'll have to tweak it according to your source. First bump H (strength) high enough to a point where it removes all noises or where it stopped removing more noise. Then work on A and S one at a time to remove noise that H haven't. At the same time gradually slide down H without introducing more noise.

A is the speed killer of the filter, on my GTX 650 ti boost, setting A from 1 to 5 had my speed dropped from 36fps to 2.97fps on a 1440x1080 clip...

Code:
clip = core.knlm.KNLMeansCL(clip, d=1, a=5, s=4, h=8)
I really want to know how the newer graphic cards do with a higher A value, because 3fps is just way too slow to me.
Code:
	SetMemoryMax(3000)
	
	colorbars(width=1440, height=1080, pixel_type="yv12").killaudio().assumefps(25, 1)
	KNLMeansCL(d=1, a=5, s=4, h=8, device_type="GPU")
MSI GTX 1080 Ti GAMING X @1961MHz ~93% GPU load

15.37fps

Code:
	SetMemoryMax(3000)
	
	colorbars(width=1920, height=1080, pixel_type="yv12").killaudio().assumefps(25, 1)
	KNLMeansCL(d=2, a=4, s=4, device_type="GPU")
MSI GTX 1080 Ti GAMING X @1961MHz ~95% GPU load

10.07fps

Last edited by edcrfv94; 14th October 2017 at 06:33.
edcrfv94 is offline   Reply With Quote
Old 14th October 2017, 20:34   #1209  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
So the newest card is 5x my speed, scaled reasonable base on the years both card came out.

And why is your card at 2G? The inform at newegg said that it has 11G.
lansing is offline   Reply With Quote
Old 14th October 2017, 21:56   #1210  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by lansing View Post
And why is your card at 2G? The inform at newegg said that it has 11G.
Methinks you're confusing video memory with clock speed.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 15th October 2017, 00:27   #1211  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 1,657
Quote:
Originally Posted by Groucho2004 View Post
Methinks you're confusing video memory with clock speed.
Ok I saw it now.
lansing is offline   Reply With Quote
Old 15th October 2017, 12:25   #1212  |  Link
Khanattila
Registered User
 
Khanattila's Avatar
 
Join Date: Nov 2014
Posts: 440
In theory you can use multiple graphics card. Actually it doesn't work because second GPU is waiting but it would be something like that:

Code:
function mGPU(clip source, int d, int a, int s) {

clipWdt = Width(source) / 2
clipHgh = Height(source)
halo = a + s

clipA = Crop(source, 0, 0,  clipWdt + halo, clipHgh)
clipB = Crop(source, clipWdt - halo, 0, clipWdt + halo, clipHgh)

clipA = KNLMeansCL(clipA, d, a, s, device_id = 0)
clipB = KNLMeansCL(clipB, d, a, s, device_id = 1)

clipA = Crop(clipA, 0, 0, clipWdt, clipHgh)
clipB = Crop(clipB, halo, 0, clipWdt, clipHgh)

return StackHorizontal(clipA, clipB)

}
__________________
github.com
Khanattila is offline   Reply With Quote
Old 5th November 2017, 00:19   #1213  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I am getting AviSynthGetFrame errors any time I try to set d>0 or a>1 using AVISynth+ on WinXP Pro 32-bit.

Here is what avsmeter reports:

Code:
E:\Documents\My Videos\AVISynth\AVISynth Plugins\plugins>avsmeter "E:\Documents\
My Videos\AVISynth\Scripts\KNL_Means Interlaced Denoising.avs"

AVSMeter 2.4.7 (x86) - Copyright (c) 2012-2017, Groucho2004
AviSynth+ 0.1 (r2508, MT, i386) (0.1.0.0)

KNLMeansCL: AviSynthGetFrame error!
I tried going back to my earlier version of AVISynth, but Groucho's swtiching batch file, unfortunately, doesn't change enough things, and I get a whole new set of errors, so I don't want to compound the troubleshooting by trying to go back to 5.8 or 6.0.

AVISynth+ seems to be better in almost every way, so I'd like to stick with it, if I can.

I am using the non-GPU version of KNLMeans, although before I did that, I went to the Intel site and downloaded and installed the latest version of OpenCL and then used the most recent version of KNLMeansCL. Since I have an older GPU (GeForce 9800 GT), I don't think I can use the GPU, even with updated drivers.

The problem I am reporting here is with KNLMeansCL-v0.6.11 (9/23/2015).

I can get the plugin to work fine if I set d=0, but unfortunately, the denoising isn't very good without using adjacent fields.

Here is the script I'm using:

Code:
loadPlugin("E:\Documents\My Videos\AVISynth\AVISynth Plugins\plugins\KNLMeansCL.dll")
#setmemorymax(1024)

d_input=0     #number of past/future frames default=1; 0=1 frame; 1=3 frames
a_input=1     #radius of search window; default=2; 0=1 pixel; 1=9 pixels
s_input=4     #radius of similarity; default=4
h_input=15.0  #filter strength
wmode_input=2 #weighting function (choose which one); default=0

source=AVISource("E:\fs.avi").KillAudio().requestlinear()
#source=AVISource("E:\fs.avi").KillAudio()

separatefields(source)
even=selecteven()
odd=selectodd()

den_even=KNLMeansCL(even,d=d_input,a=a_input,s=s_input,h=h_input,wmode=wmode_input)
del_odd=KNLMeansCL(odd,d=d_input,a=a_input,s=s_input,h=h_input,wmode=wmode_input)
interleave(den_even,del_odd)
output=weave()

#output = KNLMeansCL(source,d=d_input,a=a_input,s=s_input,h=h_input)
#return output
#return source
#stackhorizontal(source,output)

#/*
return Interleave(
\    source
\  , output
\ )
#*/

# Enable MT!
Prefetch(5)
I read a few posts earlier in this massively long thread that people had problems using this on interlaced video. Perhaps I should re-write this a little to see if I can use it on dumb bobbed video because that way I'd only have one call to the DLL. [edit]I just did that, and the bobbed version freezes in exactly the same way. Two calls is not the problem. [/end edit]

I've killed a lot of time on this, and am just going to have to use a lesser denoiser (MDegrain2) so I can finish the project. However, when I use the settings I want with KNLMeansCL, I can get a few dozen frames done before it crashes, and those are absolutely spectacular. Really good stuff.

It feels like a memory issue because it seems to fail at earlier or later frames, depending on what SetMemoryMax values I use. It is as though some data area is filling up.

Just as I was getting ready to post this, I ran it again, and my computer completely locked up and froze, like the old DOS days of the 1980s. I've had this computer for seven years, and I don't think it ever locked up like that. There is definitely something squirrely (technical term) going on under the covers.

Any hints or ideas would be greatly appreciated.

Last edited by johnmeyer; 5th November 2017 at 00:24. Reason: added info about using bob instead of separatefields()
johnmeyer is offline   Reply With Quote
Old 5th November 2017, 00:26   #1214  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,752
I remember that I can't use a current KNLMeansCL with a GeForce 9800, not even with a GTS 450. It requires a more recent OpenCL API version.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 5th November 2017, 09:48   #1215  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
@John
First of all, your card does support OpenCL 1.1 which works with KNLMeansCL 0.6.11. As for drivers, all you need is the latest Nvidia driver that works for your card (340.52). No Intel driver required.

It's most likely a memory issue. Your 9800 probably doesn't have enough memory for 2 KNLMeansCL calls and running this in 5 threads. Reduce the number of threads or run KNLMeansCL single-threaded (add "SetFilterMTMode("knlmeanscl", MT_SERIALIZED)" at the beginning of your script).

You can monitor GPU memory usage by running AVSMeter with the "-gpu" switch. GPU-Z must be running in this case.
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 5th November 2017 at 10:38.
Groucho2004 is offline   Reply With Quote
Old 5th November 2017, 17:02   #1216  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Groucho,

Many thanks! I'll do everything you recommended and report back. I actually don't know what driver version I'm running. I'm running AVISynth+ at this point, so I don't know if SetFilterMTMode will do the same thing in that environment. With AVISynth "SetMTMode" isn't used.
johnmeyer is offline   Reply With Quote
Old 5th November 2017, 17:08   #1217  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,752
Groucho2004 already mentioned SetFilterMTMode because it is an AviSynth+ feature. You can control the parallelizability per AviSynth filter function automatically for every occurence. Legacy AviSynth MT does not support that globally, you would have to switch the MT mode before and after such restricted functions.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 5th November 2017, 19:37   #1218  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
Thanks for the help but it looks like I'll have to try another avenue. I tried to install the 340.52 driver and it wouldn't install (I got an error message from the nVidia installer that it could not install). I did a little research and found that this is a common problem, so I manually installed the driver. Unfortunately I ended up with a 4-bit 640x480 display using the generic Windows driver. So I backed out of that, and as I was waiting for System Restore to complete I remembered that I'd been through this loop before a few years ago and that's why I'm stuck with the 258.96 drivers.

Also, I did try adding the

SetFilterMTMode("knlmeanscl", MT_SERIALIZED)

line to the beginning of the script, but it did not change the crash behavior at all.

So, since this a dual boot computer, I'll use this as an excuse to install AVISynth+ on my Windows 7 Pro 64-bit installation, and see if I get any better results there.

Thanks again for the help.
johnmeyer is offline   Reply With Quote
Old 5th November 2017, 20:01   #1219  |  Link
DJATOM
Registered User
 
DJATOM's Avatar
 
Join Date: Sep 2010
Location: Ukraine, Bohuslav
Posts: 377
Try 'SetFilterMTMode("knlmeanscl", MT_SERIALIZED, true)'.
DJATOM is offline   Reply With Quote
Old 5th November 2017, 20:05   #1220  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,691
I'm working on the Win7 64-bit boot drive, using the same computer. At the moment I'm using AVISynth 2.60 (2/20/2015) because that's what was already installed. I am using the script without any multi-threading (on this older version of AVISynth, all I have to do is omit the SetMTMode statements).

I've found a few interesting bugs, although since these are with the older legacy KNLMeansCL, it probably doesn't make sense to waste people's time describing them. The short version is that with wmode_input set to default ("0"), even if you set the denoiser strength to 0.01, and set "d" and "a" to zero, it still does all sorts of filtering.

It still crashes in the exact same manner as under Win XP 32-bit, and I still am not able to load any of the modern KNLMeansCL versions.

I'll keep working through this.
johnmeyer is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.