digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: Motion adaptive filtering now possible? (http://www.digitalfaq.com/archives/avisynth/3594-avisynth-motion-adaptive.html)

kwag 05-29-2003 12:31 PM

Hi ren,

Get your filter updates here :) : http://www.avisynth.org/~warpenterprises/

-kwag

ARnet_tenRA 05-29-2003 12:39 PM

Here is what I have so far: It divides the movie into 16x16 blocks and allows you to perform filtering on each block separately.

Code:

AviSource(" -Your Movie Here- ")

FilterBlocks()

function FilterBlocks( clip clip, int "cwidth", int "cheight", clip "vertclip" ) {
 cwidth = default(cwidth,0)
 cheight = default(cheight,0)
 vertclip = default(vertclip, HorizontalStrip(clip, cwidth, cheight))
 cheight = cheight+16
 cheight < clip.height ? FilterBlocks(clip, cwidth, cheight, StackVertical(vertclip,HorizontalStrip(clip, cwidth, cheight))): vertclip
}

function HorizontalStrip( clip clip, int cwidth, int cheight, clip "hortclip" ) {
 hortclip = default(hortclip, Crop(clip,cwidth,cheight,16,16).filters())
 cwidth = cwidth+16
 cwidth < clip.width ? HorizontalStrip(clip, cwidth, cheight, StackHorizontal(hortclip,Crop(clip,cwidth,cheight,16,16).filters())): hortclip
}

function filters( clip clip ) {
greyscale(clip)
}

You can place whatever filters you want in the filters function.

Again I used greyscale to show that every block is being filtered.

Regards, Tenra

rendalunit 05-29-2003 01:14 PM

thanks kwag,

All the filters load fine now but I'm still getting the "I don't know what SubBlur means" error :roll:

ren

kwag 05-29-2003 01:18 PM

Quote:

Originally Posted by rendalunit
thanks kwag,

All the filters load fine now but I'm still getting the "I don't know what SubBlur means" error :roll:

ren

You're using some stray variables and lines that I had defined for display purpose as sub-titles :!:
Make sure your script looks like this:

Code:

LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
 LoadPlugin("C:\Filters25\STMedianFilter.dll")
 LoadPlugin("C:\Filters25\UnFilter.dll")
 LoadPlugin("C:\Filters25\BlockBuster.dll")
 
 Mpeg2Source("K:\VIDEO_TS\project.d2v")
 
 MaxThreshold=1.58
 
 UnFilter(50, 50)
 BicubicResize(528, 368, 0, 0.6, 16, 0, 688, 480)
 STMedianFilter(8, 32, 0, 0 )
 TemporalSoften(2,7,7,3,2)
 mergechroma(blur(1.50))
 
 ### Dynamic Adaptive Filtering ###
 val=0 # Initialize our motion variable.
 N="noise"
 
 FrameEvaluate("val=YDifferenceFromPrevious()/14.55") # Assign "val" with difference between current frame and last frame.
 ScriptClip("val > MaxThreshold ? MergeLuma(blur(MaxThreshold)) : MergeLuma(blur( val )) ") # Adaptive mergeluma.
 AddBorders(0, 56, 0, 56)
 LetterBox(16, 16, 16, 16)
 Limiter()

And just make the changes to your source line, resize, addborders and letterbox.

-kwag

kwag 05-29-2003 01:33 PM

704x480 Showoff !!!
 
And here's the showoff for the day :mrgreen:
www.kvcd.net/704x480-showoff.mpg ( CQ=68 MIN=300, MAX=2,500 ~6MB 25 seconds :!:, which should be about the right CQ to fit this particular movie on one CD, looking just like this sample 8) )

Enjoy!,
-kwag

rendalunit 05-29-2003 01:38 PM

Quote:

Originally Posted by kwag
You're using some stray variables and lines that I had defined for display purpose as sub-titles

Yep, I finally figured that out :teeth:

now I'm getting strange noise from blockbuster:

http://www.digitalfaq.com/archives/i.../2003/05/1.png

could this be because of the Variance param becoming invalid?

ren

rendalunit 05-29-2003 01:48 PM

Quote:

Originally Posted by kwag
And here's the showoff for the day
www.kvcd.net/704x480-showoff.mpg ( CQ=68 MIN=300, MAX=2,500 ~6MB 25 seconds , which should be about the right CQ to fit this particular movie on one CD, looking just like this sample

Wow!!! :jawdrop: That looks great!!

btw- what movie is that? I'm going to rent it :D

ren

kwag 05-29-2003 01:52 PM

Hi ren,

I didn't protect the variance in the sample script, but that was just for a test, so don't take it seriously :lol:
The proper way would be using calculations to limit the min and max boundaries, before applying the value to variance. Like another conditional operator "?" to bracket the values.
I really see no need for Blockbuster above 528x resolutions :?
And specially now, that I think we can even go up to 704x480, as in the sample I posted :!:
The dynamic value applied to mergeluma function really saves us a huge amount of data, so I think we can now start to use XVCD 704x480(576) resolution with this methods. This can only get better from now on 8)

-kwag

kwag 05-29-2003 01:53 PM

Quote:

Originally Posted by rendalunit

Wow!!! :jawdrop: That looks great!!

btw- what movie is that? I'm going to rent it :D

ren

"The Foreigner" :)

-kwag

bman 05-29-2003 02:31 PM

Quote:

Originally Posted by rendalunit
Quote:

Originally Posted by kwag
You're using some stray variables and lines that I had defined for display purpose as sub-titles

Yep, I finally figured that out :teeth:

now I'm getting strange noise from blockbuster:

http://www.digitalfaq.com/archives/i.../2003/05/1.png

could this be because of the Variance param becoming invalid?

ren

@ ren
To get rid of noise blocks I did some changes in BlockBuster line :
ScriptClip("val < 0.3 ? BlockBuster(method=N, detail_min=10, detail_max=15, variance=(1/val*10), seed=0) : val > 1 ? blur(1.58) : blur(val)")
This values I get by testing (encoding sample) and I'm quite sure that thay
will be different for different sources (dvd's) .
I think best is if u check min - max values for your source and according that adjust tham .
I hope it's helpful
bman

DorvalCS 05-29-2003 02:36 PM

I figured it out :idea: :idea:

I was running into this problem earlier today
<<When I load the script in VirtualDub I get this error message:
"Couldn't locate decompressor for format YV12" >>

I have downloaded and installed the Video Codec "ATI YV12 4:2:0 Planar v.4.12.5038".... No more problem. :oops: I don't know if that's what I was suppused to do... But it fixed my problem :lol:

I'm now in full testing mode for thise new 2.5 Script... Can't wait to see some relusts.. :wink:

bman 05-29-2003 02:45 PM

@ all
Any suggestions for VoBSub or TextSub for Avs2.5
bman

ozjeff99 05-29-2003 08:32 PM

Kwag....704x576 woohoo. Since I can't do KVCDx3 this is very tasty. Great work everyone! :P
ozjeff99

ovg64 05-29-2003 08:52 PM

Finally i took some time and got these thing going with avs2.51, now it would be nice if MovieStacker would generate our avs scripts again. :mrgreen:

kwag 05-29-2003 09:12 PM

Quote:

Originally Posted by ovg64
now it would be nice if MovieStacker would generate our avs scripts again. :mrgreen:

It's just a matter of time, and a matter of muaddib getting his motheboard fixed :!: His machine went bad (again!) last week, and he told me he would be unavailable for some days until he gets his system fixed. I'm sure he will be surprised when he logs back on :mrgreen:

-kwag

ozjeff99 05-30-2003 12:19 AM

The Motherboard is not broken it is very very tired. Speak to it Muad :wink:

I'm wondering with this application in tandem with a normal Mpeg-1 encoding process whether a new standard is being created..

.....Mpeg-1.5 :?

ozjeff99

audioslave 05-30-2003 01:58 AM

Good morning!

@kwag
Have you tried lowering the maximum bitrate yet? I read that you would try it...
Wow, my head is spinning! This new script really is amazing! Can we finally use 704x576/480 for our encodes?
Another thing: Are you supposed to change the maximum numer of frames per GOP depending on your source? Like 24 for NTSCFilm, 25 for PAL and 30 for NTSC?
Here I go again, bombing you with questions :wink:

And, yes, that "The Foreigner" clip looks simply AWESOME!!! :lol: Did you use the latest Optimal Script for AviSynth 2.5* for that one?

kwag 05-30-2003 05:52 AM

Quote:

Originally Posted by audioslave
Good morning!

@kwag
Have you tried lowering the maximum bitrate yet? I read that you would try it...

Yes, at 528x480 (KVCDx3) I tried a MAX of 2000Kbps and the result is great :)
Quote:

Wow, my head is spinning! This new script really is amazing! Can we finally use 704x576/480 for our encodes?
I think so :!:, just like that sample of "The Foreigner". I used ToK to predict the real CQ with the current script, and it came out to "CQ=63.65" :) Not far from that sample I did at CQ=68, and I did the complete movie with ToK at 704x480 to fit on one CD and looks just like that sample I posted :mrgreen:
I did use a MAX bitrate of 2,500, because at that resolution we need that bit rate for fast action scenes. However, at 528x480, I think we can get by with the MAX of 2000 using the new adaptive script.
Quote:

Another thing: Are you supposed to change the maximum numer of frames per GOP depending on your source? Like 24 for NTSCFilm, 25 for PAL and 30 for NTSC?
If you use ToK, that's exactly what it does automatically, depending on your source frame rate :)
Quote:

Here I go again, bombing you with questions :wink:

And, yes, that "The Foreigner" clip looks simply AWESOME!!! :lol: Did you use the latest Optimal Script for AviSynth 2.5* for that one?
You bet :!:, the one that's currently posted :)

-kwag

audioslave 05-30-2003 06:22 AM

WOW!
Can you use ToK with AviSynth 2.5*? When I tried that TMPGEnc said I had the wrong sampler.dll version... Where can I find a sampler.dll version to work with the new linear script and AviSynth 2.5*?

Krassi 05-30-2003 07:29 AM

Quote:

Originally Posted by audioslave
WOW!
Can you use ToK with AviSynth 2.5*? When I tried that TMPGEnc said I had the wrong sampler.dll version... Where can I find a sampler.dll version to work with the new linear script and AviSynth 2.5*?

@audioslave:
You can get the newest Sampler here:
http://www.jungleweb.net/~sansgrip/avisynth

I have just used ToK and had no problems with the current 2.51 script.

audioslave 05-30-2003 07:36 AM

Thank you Krassi! :D
I'll download it right away...

jorel 05-30-2003 09:05 AM

with this script (copied from Kwag posted here),
when i try to load in ToK with the new sampler(Krassi-thanks) :wink:
i got:
" invalid argument to time encode "
and the file don't load!
i did a folder called "filters25" with all news dlls for avisynth251.

see ToK log:
================================================== ===========
ToK Log: C:\Meus documentos\kwag.avs
================================================== ===========

Resolution (fps):0x0 (00,000 fps)
Total Frames: 0

the script:
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\UnFilter.dll")
LoadPlugin("C:\Filters25\BlockBuster.dll")

Mpeg2Source("D:\La Luna\Segment2\DVD2AVI_PROJECT_FILE.d2v")

MaxThreshold=1.58

UnFilter(50,50)
BicubicResize(448,448,0,0.6,0,0,720,480)
STMedianFilter(8,32,0,0)
TemporalSoften(2,7,7,3,2)
mergechroma(blur(1.50))

### Dynamic Adaptive Filtering ###
val=0 # Initialize our motion variable.
N="noise"

FrameEvaluate("val=YDifferenceFromPrevious()/14.55") # Assign "val" with difference between current frame and last frame.
ScriptClip("val > MaxThreshold ? MergeLuma(blur(MaxThreshold)) : MergeLuma(blur( val )) ") # Adaptive mergeluma.
AddBorders(16,16,16,16)
LetterBox(16,16,16,16)
Limiter()

help please, don't know what's going wrong! :(
:?
any help will be fine.
:wink:

kwag 05-30-2003 09:25 AM

Hi jorel,

Make sure you're using the latest version of avisynth 2.51. Don't use the one posted on the page at sourceforge.net. Get the latest build from sh0dan's link, available on his signature.

-kwag

jorel 05-30-2003 09:28 AM

8O
ok faster double click!
:lol:

thank you.

jorel 05-30-2003 10:34 AM

no more problems
:D

the script is great and faster.
intall avisynth251 ffvfw option!!!

8)

kwag 05-30-2003 10:51 AM

Quote:

Originally Posted by jorel
:(
more information from my error:
when i try to open the script in VirtualDub i got:

VirtualDub error

"couldn't locate decompressor for format 'yv12' (unknow)

Add "ConvertToYV12()" after your source line ;)

-kwag

jorel 05-30-2003 11:00 AM

Quote:

Originally Posted by kwag
Quote:

Originally Posted by jorel
:(
more information from my error:
when i try to open the script in VirtualDub i got:

VirtualDub error

"couldn't locate decompressor for format 'yv12' (unknow)

Add "ConvertToYV12()" after your source line ;)

-kwag

don't work Kwag,same error :!:

:?

kwag 05-30-2003 11:03 AM

I don't know what's going on jorel 8O
Maybe your MPEG2DEC3 version :idea:
I don't have a single problem with the script as it is, and it's working fine here even with ToK, doing prediction and encoding :!:

-kwag

jorel 05-30-2003 11:09 AM

Quote:

Originally Posted by kwag
I don't know what's going on jorel 8O
Maybe your MPEG2DEC3 version :idea:
I don't have a single problem with the script as it is, and it's working fine here even with ToK, doing prediction and encoding :!:

-kwag

i know Kwag,the script is fantastic,i read all posts and
you send me a big sample...is really cool!
:!:

my version of MPEG2DEC3 is from 19-01-03.
this was the last that i got!

where i find the new?
:)

kwag 05-30-2003 11:15 AM

Quote:

Originally Posted by jorel

my version of MPEG2DEC3 is from 19-01-03.
this was the last that i got!

So is my version :!:
Have you tried another source :idea:

-kwag

DorvalCS 05-30-2003 11:15 AM

Quote:

Originally Posted by jorel
:(
more information from my error:
when i try to open the script in VirtualDub i got:

VirtualDub error

"couldn't locate decompressor for format 'yv12' (unknow)

:?

Jorel... I had the exact same problem... And I fixed this by going to this site http://mirror01.iptelecom.net.ua/~video/ and I downloaded this Video Codec <<ATI YV12 4:2:0 Planar v.4.12.5038>>> and installed it.
This fixed my problem. I can now use the script.... That being said, I have a question for Kwag and others.... What codec are you using??? I don't even know if this is the right one... 8O

Hope this helps...
:)

jorel 05-30-2003 11:23 AM

DorvalCS

thanks for help me too!
:wink:

i only did like you post in another thread:
"Reinstalled only AviSynth 2.51 WITH (I think this is where I went wrong the first time) ffvfw option!!!"

:D

DorvalCS 05-30-2003 11:25 AM

Jorel,

Just tried the link again.... veeeerrrrrryyyyy slow!!! But it works. :wink:

I'm afraid I don't have another link.

jorel 05-30-2003 11:31 AM

believe me friend,
i post this link here in few months ago.

:lol: :lol: :lol: :lol:

i knew it but forgot. :oops:

thank you very much,now is coming.
:D

Krassi 05-30-2003 11:31 AM

Hi Jorel,
try again with this link
http://mirror01.iptelecom.net.ua/~vi...oder.v4.12.exe

I had the same problem and my solution was
Mpeg2Source("D:\Recorder\movie.d2v")
ConvertToYV12()
(as Kwag already said :D ).

DorvalCS 05-30-2003 11:38 AM

:D

Glad I can help... For a change!!!

I usually come here and benefit from all the hard work you guys are putting into this project :D

jorel 05-30-2003 11:38 AM

right between the eyes.
:D

works fantastic now :!:

thank you DorvalCS my friend :wink:

this is a big hint for all that got the same problem.

thank you too Krassi,i see you in the "preview".

you all are great :!:

:D

sbin 05-30-2003 12:51 PM

Quote:

And I fixed this by going to this site http://mirror01.iptelecom.net.ua/~video/ and I downloaded this Video Codec <<ATI YV12 4:2:0 Planar v.4.12.5038>>> and installed it.
You can also solve this issue by using VirtualDubMod, which is patched with internal YV12 support. Regular VirtualDub doesn't support YV12 without some support codecs, which can be a pain, as you see. :lol:

http://virtualdubmod.sourceforge.net

rendalunit 05-30-2003 03:28 PM

i changed the script to blur more on motion scenes:
Code:

Loadplugin("C:\encoding\filters25\MPEG2Dec3.dll")
Loadplugin("C:\encoding\filters25\Decomb.dll")
Loadplugin("C:\encoding\filters25\Deen.dll")
Loadplugin("C:\encoding\filters25\Sampler25.dll")
Loadplugin("C:\encoding\filters25\STMedianFilter.dll")

Mpeg2Source("D:\source.d2v")

Deen("m2d",1,10,12)
TemporalSoften(2,7,7,3,2)

BicubicResize(512, 462, 1/3, 1/3, 5, 0, 710, 480)
val=0
FrameEvaluate("val=YDifferenceFromPrevious()")
#ScriptClip("Subtitle(string(val))")
ScriptClip("val>=10 && val<15 ? blur(1.58).blur(1.58) :  mergechroma(blur(1.50)).mergeluma(blur(0.2))")
ScriptClip("val>=15 ? blur(1.58).blur(1.58).blur(1.58) :  mergechroma(blur(1.50)).mergeluma(blur(0.2))")

AddBorders(8, 9, 8, 9)
Limiter()

I'm getting really good compression with this script (probably because there's so much blurring and denoising :D ) Deen seems really fast too. I thought that when the Y difference between frames was > 15 then lots of blurring wouldn't be very noticeable but the problem is that when there's a scene change then the first frame of the new scene is blurry :roll:

ren

DorvalCS 05-30-2003 03:49 PM

Did anyone of you compare a scene (or frame) from this new script to the same scene created with the last "optimal script" for AviSynth 2.0x?

With this new adaptive script I noticed that the colors were washed out... It is especially noticeable with the black :?

Is it just me?


All times are GMT -5. The time now is 01:17 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.