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)

Racer99 06-02-2003 11:06 AM

Quote:

Originally Posted by kwag
Quote:

Originally Posted by Racer99
Keep it up and pretty soon we'll be able to put a whole movie on my 256mb Thumb Drive.

If you have a Pocket PC, you can put "The Matrix" on one 128MB flash card :!:, and it looks pretty damn good on the iPaq screen :D
I did that a long time ago, without any of the latest techniques, so now it would probably look even better 8)

-kwag

Unfortunately no I don't have a Pocket PC (no real need for one). I was just comparing about how we have learned better techniques that have led to better compression without visible loss of quality since you have (we have) started working on improving this craft.

Keep up the good work guys :D .

Racer99

black prince 06-02-2003 09:04 PM

@Kwag,

My test was Drumline DVD, 118 minutes, full screen, low action movie,
and the target filesize was one 80 minute CD. Tok file prediction was
very low for 704x480 (CQ 15), 528x480 (CQ 19) and 352x480 (CQ 30).
I used the current Optimal Script for v2.5x and default settings for
VCD in Tok.

1) ToK CQ predictions at any resolution very low :cry:

2) Encoding time veeeeeeerrrrry slooooooooow :cry:

3) Filesize bigger than using avisynth 2.08 :cry:

4) Picture quality pooooor (due to low CQ prediction) :cry:

I've got to wonder if this process is better than using avisynth 2.08+ :roll:

-bp

kwag 06-02-2003 09:09 PM

8O Something is WAY wrong bp :!:
My encoding with the current script and 2.52 is much faster than with 2.08.
Have you tried deinstalling 2.08 completely, and then installing 2.52 :idea:
The quality I have achieve now has surpassed any previous encoding I have ever done before. There's just no comparison :D

-kwag

black prince 06-02-2003 09:22 PM

@Kwag,

Kwag wrote:
Quote:

Something is WAY wrong bp
My encoding with the current script and 2.52 is much faster than with 2.08.
Have you tried deinstalling 2.08 completely, and then installing 2.52
The quality I have achieve now has surpassed any previous encoding I have ever done before. There's just no comparison
I uninstalled avisynth 2.08 before installing 2.5.2. Everything runs without
errors, but Tok file predictions are much lower than 2.08 for the same
resolutions. Encoding times are 15+ hours at 352x240 instead
of 5 to 6 with v2.08. Filesize is also gaining weight with v2.5.2. I don't
know what magic you're using but I can't seem to duplicate anything
close to the picture quality you've getting :?

LoadPlugin("E:\DVD BACKUP\1 - DVD2KVCD\3 - MOVIESTACKER\Filters25\MPEG2Dec3.dll")
LoadPlugin("E:\DVD BACKUP\1 - DVD2KVCD\3 - MOVIESTACKER\Filters25\Unfilter.dll")
LoadPlugin("E:\DVD BACKUP\1 - DVD2KVCD\3 - MOVIESTACKER\Filters25\STMedianFilter.dll")
## Defined Variables and Constants ##
#
MaxTreshold = 1.58
scd_trigger = 15 # Scene change trigger value.
cf = 0 # Current frame.
lf = 0 # Last frame
val = 0 # Dynamic value applied to filters
#
####

## Main section and static filters ###
#

Mpeg2Source("D:\Temp\movie.d2v")

Limiter()
UnFilter(50, 50)
BicubicResize(528,480)
STMedianFilter(8, 32, 0, 0 )
TemporalSoften(2,7,7,3,2) # Experimental!
MergeChroma(blur(1.50))
MergeLuma(blur( 0.1))
#
####

## Dynamic Linear Adaptive filtering and Scene Change Detection ##
#
FrameEvaluate("cf = YDifferenceToNext()")
FrameEvaluate("val = (cf / 16) + 0.1")
ScriptClip("((cf - lf) < scd_trigger) ? (val < MaxTreshold) ? MergeLuma(blur(val)) : MergeLuma(blur(MaxTreshold)) : MergeLuma(blur(1.5))")
#
####

#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
#AddBorders( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()
FrameEvaluate("lf = YDifferenceToNext()")
#
####

-bp

kwag 06-02-2003 09:36 PM

Hi bp,

Could this be a processor related issue :?:
I'm on a P4 @1.6Ghz. Are you on Intel or AMD :?:

-kwag

kwag 06-02-2003 10:54 PM

Bug Squashed !!!
 
New script posted :!:

:imstupid: There was an almost invisible problem on the previous posted script. It was very hard do see, but it was present if you looked at your .avs and moved frame by frame with VirtualDub. The third frame after every scene change was slightly blurred, in comparison to the adjacent frames. It's been squashed :!: :gun: I also added a "Version" to the script, so we can all keep track of the last date/time modified. I hope this script can now create a basic framework so we all can grow it, and apply different filters (if nedded!) for different filtering strategies.

-kwag

DKruskie 06-02-2003 11:07 PM

Im using the newest script posted, but while the movie is encoding I get this green bar along the right side in TMPGenc. Does anyone know what causes this?..Here is my script from TOK

## DLL Section ##
#
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\UnFilter.dll")
#
####

## Defined Variables and Constants ##
#
MaxTreshold = 1.58
scd_trigger = 15 # Scene change trigger value.
nf = 0 # Current frame.
lf = 0 # Last frame
val = 0 # Dynamic value applied to filters
#
####

## Main section and static filters ###
#
Mpeg2Source("C:\DVD\matrix.d2v")
Limiter()
UnFilter(50, 50)
BicubicResize( 352,240,0,0.6,8,0,740,480 )
STMedianFilter(8, 32, 0, 0 )
TemporalSoften(2,7,7,3,2) # Experimental!
MergeChroma(blur(1.50))
MergeLuma(blur( 0.1))
#
####

## Dynamic Linear Adaptive filtering and Scene Change Detection ##
#
FrameEvaluate("lf = YDifferenceToNext()")
FrameEvaluate("nf = YDifferenceToNext()")
FrameEvaluate("val = (lf / 16) + 0.1")
ScriptClip("((nf - lf) < scd_trigger) ? (val < MaxTreshold) ? \
MergeLuma(blur(val)) : MergeLuma(blur(MaxTreshold)) : \
( (sign(nf-lf)) != -1) && (val < MaxTreshold) ? MergeLuma(blur(val)) : MergeLuma(blur(.75)) ")
#
####

#LetterBox( 16,16,16,16 ) # Depends on situation. Use MovieStacker!
#AddBorders( 16,16,16,16 ) # Depends on situation. Use MovieStacker!
Limiter()
#
####
AssumeFPS(23.976)
LoadPlugin("C:\TOK\ToK_EXTRAS\Sampler\Sampler-2.5.dll")
oldfps = framerate
interval = round((FrameCount/24)/59.940)/10
nFrames = round(24)
SelectRangeEvery( (round(framecount/interval)),nFrames)


David

kwag 06-02-2003 11:34 PM

Quote:

Originally Posted by DKruskie
Im using the newest script posted, but while the movie is encoding I get this green bar along the right side in TMPGenc.

What green bar David 8O :?:

-kwag

girv 06-03-2003 05:27 AM

Quote:

Originally Posted by kwag
Quote:

Originally Posted by girv
Have you considered using a non-linear motion->blur function?

No, because the whole idea of the linear adaptation is indeed to produce the sharpest result on slowest motion,

Yeah I get that, I was just floating the idea of a nonlinear function as it could possibly produce visually better results - less blurring on more low motion scenes, but increased blurring with higher motion. Im normally working with low quality non-DVD sources so I'd like to maintain as much noticeable detail as possible, only blurring when it won't be noticed.

Ignore me, Im just thinking "out loud" :)

Quote:

Originally Posted by kwag
Quote:

Originally Posted by girv
I'm also not sure if I agree with lf=YDifferenceToNext being at the end of the script,

That's just to read the value of the following frame, and use it as the variable as last frame for comparison on the next iteration

Yep, but with the line at the end I thought you might be comparing the filtered current frame with the non-filtered next frame (which seemed wrong), but I'm not sure which next frame (filtered or not) AVISynth would use for YDifferenceToNext (sh0dan?)

Anyway you've changed the script now so it doesn't matter :)

girv 06-03-2003 05:41 AM

Re: Bug Squashed !!!
 
Quote:

Originally Posted by kwag
The third frame after every scene change was slightly blurred, in comparison to the adjacent frames.

I've been experimenting with blurring 2-3 frames after the scene change, the theory being that at 24fps 3 frames ~= 0.1s which is the shortest time interval your eyes can react to (like your eyes run at 10Hz :). Should give more compression for no visual difference...I think :)

kwag 06-03-2003 07:38 AM

Re: Bug Squashed !!!
 
Quote:

Originally Posted by girv

I've been experimenting with blurring 2-3 frames after the scene change, the theory being that at 24fps 3 frames ~= 0.1s which is the shortest time interval your eyes can react to (like your eyes run at 10Hz :). Should give more compression for no visual difference...I think :)

Yes, it might be a good idea to try, maybe blur the two frames after the scene change :idea: I'm not sure if I would blur 3 frames though :?, it might be visible. How about bluring the frame "before" the scene change, and 2 frames "after" the scene change :idea: :idea:
Right now, the script blurs only the frame after a scene change, using mergeluma(blur(MaxTreshold)).

-kwag

kwag 06-03-2003 09:00 AM

Problem with mergeluma now corrected.
 
I've found what's possibly a bug in AviSynth and/or mergeluma.
After doing a test encode, I see some scenes where there's no scene change at all, and one frame slightly increases brightness. It looks like a small "flash". I've traced the problem to be when mergeluma blur value makes a transition from around ~0.180 to ~0.205.
I've corrected this by changing the minimum value to be 0.2.
So now mergeluma fluctuates between min=0.2 to max=1.58.
I have been able to reproduce the problem consistently. Here's a very short mpeg file which shows the effect:

www.kvcd.net/flash.mpg

And here's the same clip with the corrected min of .2 showing a clean clip:
www.kvcd.net/no-flash.mpg

The current script posted corrected this.

-kwag

Jellygoose 06-03-2003 09:04 AM

Quote:

Originally Posted by kwag
Hi bp,

Could this be a processor related issue :?:
I'm on a P4 @1.6Ghz. Are you on Intel or AMD :?:

-kwag

I'm on AMD Athlon XP1800+ and the new script looks beautiful... :roll:

girv 06-03-2003 09:18 AM

Re: Problem with mergeluma now corrected.
 
Quote:

Originally Posted by kwag
I've found what's possibly a bug in AviSynth and/or mergeluma

Aggh! Beat me to the Submit button :D I'd noticed this as well and the 0.1-0.2 transition point. Thanks for the fix!

kwag 06-03-2003 09:20 AM

Re: Problem with mergeluma now corrected.
 
Quote:

Originally Posted by girv
Quote:

Originally Posted by kwag
I've found what's possibly a bug in AviSynth and/or mergeluma

Aggh! Beat me to the Submit button :D I'd noticed this as well and the 0.1-0.2 transition point. Thanks for the fix!

:wink:
I just PM'ed sh0dan about it :)

-kwag

audioslave 06-03-2003 09:46 AM

Just a quick (and stupid :oops: ) question...

Where in the script are you supposed to put the lines:

FieldDeinterlace()
or
Telecide()
Decimate()

Am I correct to presume I should put them directly after the first Limiter() line?

Newbie warning, I know... Sorry! :roll:

kwag 06-03-2003 09:48 AM

Quote:

Originally Posted by audioslave
Just a quick (and stupid :oops: ) question...

Where in the script are you supposed to put the lines:

FieldDeinterlace()
or
Telecide()
Decimate()

Am I correct to presume I should put them directly after the first Limiter() line?

Newbie warning, I know... Sorry! :roll:

Put them right after the source line where you open the .d2v :)

-kwag

audioslave 06-03-2003 09:50 AM

Thanks kwag! :wink: I just wanted to be sure to get it right.
You're the Man! 8)

sh0dan 06-03-2003 10:01 AM

I need a simple script to reproduce this.

Does this happend with or without mergeluma? (When you just blur)?

DorvalCS 06-03-2003 10:02 AM

Hi Kwag,

In testing the new script I have noticed that on scenes with very little action the image seems to shift from left to right.... The Scene I'm looking at is from the movie "Meet the Parents" when they are at the dinner table. You can see the glass wine move from left to right... I have just tried this a couple of minutes ago with the last script you posted.

I don't notice this effect in scene with action/movement... Have you notice the same?

kwag 06-03-2003 10:08 AM

Quote:

Originally Posted by sh0dan
I need a simple script to reproduce this.

Does this happend with or without mergeluma? (When you just blur)?

Hi sh0dan,

You can reproduce the effect with the current script, which is this:

Code:

## DLL Section ##
#
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\UnFilter.dll")
#
####

## Defined Variables and Constants ##
#
MaxTreshold = 1.58
scd_trigger = 15 # Scene change trigger value.
nf =  0 # Current frame.
lf =  0 # Last frame
val = 0 # Dynamic value applied to filters
#
####

## Main section and static filters ###
#
Mpeg2Source("Your_D2V_Source_Here")
Limiter()
UnFilter(50, 50)
BicubicResize( Your_Resize_Values_Here )
STMedianFilter(8, 32, 0, 0 )
TemporalSoften(2,7,7,3,2) # Experimental!
MergeChroma(blur(1.50))
#
####

## Dynamic Linear Adaptive filtering and Scene Change Detection ##
#
FrameEvaluate("lf = YDifferenceToNext()")
FrameEvaluate("nf = YDifferenceToNext()")
FrameEvaluate("val = (lf / 16) + 0.2")
ScriptClip("((nf - lf) < scd_trigger) ? (val <  MaxTreshold) ? \
MergeLuma(blur(val)) : MergeLuma(blur(MaxTreshold)) : \
( (sign(nf-lf)) != -1) && (val < MaxTreshold) ? MergeLuma(blur(val)) : blur(MaxTreshold).blur(MaxTreshold).blur(MaxTreshold).blur(MaxTreshold)")
#
####

#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
#AddBorders( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()
#
####

And change the line that reads FrameEvaluate("val = (lf / 16) + 0.2") to read FrameEvaluate("val = (lf / 16) ")
That will make the value for mergeluma to go from ~0 to 1.58

-kwag

kwag 06-03-2003 10:12 AM

Quote:

Originally Posted by DorvalCS
Hi Kwag,

In testing the new script I have noticed that on scenes with very little action the image seems to shift from left to right.... The Scene I'm looking at is from the movie "Meet the Parents" when they are at the dinner table. You can see the glass wine move from left to right... I have just tried this a couple of minutes ago with the last script you posted.

I don't notice this effect in scene with action/movement... Have you notice the same?

No, but I would suspect that it would be caused by the STMedian filter :idea:
Try removing that filter and encode that scene. I don't think it's related at all to the current script, which basically changes luma values. The other filters are applied statically and evenly throughout all frames. So I don't think luma variations, specially low variations, would make any shifting of pixels.

-kwag

sh0dan 06-03-2003 10:51 AM

@kwag: "Simple"???

Anyway - it would seem like it is a blur() issue. It's coded by someone who isn't any longer in touch with us, so it might be hard to track down. For now - you seem to do fine with values > 0.2!

girv 06-03-2003 10:51 AM

Quote:

Originally Posted by DKruskie
Im using the newest script posted, but while the movie is encoding I get this green bar along the right side in TMPGenc

Could it be this ?

doom9: green pixels in leftmost column, but only when using Virtualdub to decode XviD fourCC

Jellygoose 06-03-2003 11:53 AM

:( that kinda sucks that we have to stick with Blur values >0.2 ...
I still think this blurs the picture a lot, even at 704x480/576...
Well I guess we have to live with it...

DorvalCS 06-03-2003 11:55 AM

Quote:

Originally Posted by kwag

No, but I would suspect that it would be caused by the STMedian filter :idea:
Try removing that filter and encode that scene. I don't think it's related at all to the current script, which basically changes luma values. The other filters are applied statically and evenly throughout all frames. So I don't think luma variations, specially low variations, would make any shifting of pixels.

-kwag

That didn't fix the problem 8O

Are you interested in seing a small sample? Follow this link:
http://www.geocities.com/dorvalcs/meettheparents.zip

The file is less than 700k... But it is very noticeable!

I'm cureous to see what you think... As usual! :wink:

kwag 06-03-2003 12:12 PM

Quote:

Originally Posted by Jellygoose
Well I guess we have to live with it...

Don't worry :!:
We'll find a fix or a workaround in a few "centons" :mrgreen:

-kwag

kwag 06-03-2003 12:12 PM

Quote:

Originally Posted by DorvalCS

Are you interested in seing a small sample? Follow this link:
http://www.geocities.com/dorvalcs/meettheparents.zip

Says link is unavailable :!:

-kwa

DorvalCS 06-03-2003 12:21 PM

Quote:

Originally Posted by kwag
Says link is unavailable :!:

-kwag

Sorry... :oops: Try again... I setup this site especially so that I could share files like this... The link is available now.

Thanks for taking the time to look at it!!

kwag 06-03-2003 12:38 PM

The 0.2 luma problem fixed!
 
Get rid of STMedianFilter NOW :!: :twisted:
It screwes up the luma somehow :!: That was the problem.
I just found that out, and I just updated the script. Now the luma varies from 0 to MaxTreshold again, for an extra "crispy" movie without "flashes"

Edit: This sucks :!: The STMFilter definitely causes a shift in color balance at some scenes, but I'm still getting some flashes when I lowered the value to MIN on luma. So I guess we'll have to stick to 0.2 for a while until this is further debugged :cry: :evil:

-kwag

kwag 06-03-2003 12:55 PM

Quote:

Originally Posted by DorvalCS

Thanks for taking the time to look at it!!

I can see it clearly, but it's the whole frame shifting :!:
Are you positive this doesn't show, even minimal, if you encode without filters :?:

-kwag

DorvalCS 06-03-2003 01:45 PM

Quote:

Originally Posted by kwag

I can see it clearly, but it's the whole frame shifting :!:
Are you positive this doesn't show, even minimal, if you encode without filters :?:

-kwag


Mmmmmm.... I should have done this before :oops: ... I've been encoding all morning with various setting to see how I could get rid of this :evil:

After removing ALL the filters... The image is still shifting :x

Sooooooo.... I put my DVD in my player.... And guess what??? The shifting is part of the source :oops: :oops: :oops:

Oh boy!!! Sorry for the trouble Kwag... Next time I'll know what to look at first :wink:

kwag 06-03-2003 01:47 PM

Quote:

Originally Posted by DorvalCS

Oh boy!!! Sorry for the trouble Kwag... Next time I'll know what to look at first :wink:

No trouble at all. I do that too :twisted: :lol:

-kwag

jorel 06-03-2003 03:05 PM

Kwag,

i test all the last scripts from 2 days ago at the last.(really new)
i ever see that less filters is better,
is a question of choice of arguments like you did...and you was great :!:
the last script is faster and give more details. :wink:
i can't find words to write sometimes and
the opinions of girv are great to me.
i can speak like he posted.
he always see the same as me and he wrote with big details.

go ahead friends, is really better.

:wink:

thanks.

kwag 06-03-2003 03:59 PM

Would some kind soul care to test this please :roll:
I hope I'm finally hitting the nail correctly, and hope that we can all have a stable script that we can start to depend on, without changing every hour :!:

Hopefully, this one won't "blink" :!: This one also blurs the frames adjacent to a scene change. That is, the frame before the scene change, AND the frame after the scene change. Not visibly detectable, but softer to the encoder and final file size.
Encode a small clip, and then load it up in Vdub. Move slowly through your clip, and notice the scene changes. See if you can see the small blur between scene changes and if there are any frames with any color bleed or flashes. THERE SHOULDN'T. I'm trying to reproduce the problems, but right now I can't. It seems that it's working. I added the STM filter again, because apparently it was some interaction with STM and the way scene detection was working. I really can't pin point what was happening. But the way the script is now, it seems that the anomalies don't show anymore 8O
I won't update the current script until I see some reports about this script that it works flawlessly :!:

Code:

## DLL Section ##
#
LoadPlugin("C:\Filters25\MPEG2Dec3.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\UnFilter.dll")
#
####

## Defined Variables and Constants ##
#
MaxTreshold = 1.58
scd_trigger = 15 # Scene change trigger value.
nf =  0 # Current frame.
lf =  0 # Last frame
val = 0 # Dynamic value applied to filters
#
####

## Main section and static filters ###
#
Mpeg2Source("Your_D2V_Source_Here")
Limiter()
UnFilter(50, 50)
BicubicResize( Your_Resize_Values_Here )
STMedianFilter(8, 32, 0, 0 )
TemporalSoften(2,7,7,3,2) # Experimental!
MergeChroma(blur(1.50))
#
####

## Dynamic Linear Adaptive filtering and Scene Change Detection ##
#
FrameEvaluate("lf = YDifferenceToNext()")
FrameEvaluate("nf = YDifferenceToNext()")
FrameEvaluate("val = (lf / 16) + 0.05")
ScriptClip("(abs(nf - lf) < scd_trigger) ? (val <  MaxTreshold) ? \
mergeluma(blur(val)) : mergeluma(blur(MaxTreshold)) : \
( (sign(nf-lf)) != -1) && (val < MaxTreshold) ? mergeluma(blur(val)) : mergeluma(blur(MaxTreshold)).mergeluma(blur(MaxTreshold))")
#
####

#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
#AddBorders( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()
#
####


ovg64 06-03-2003 04:29 PM

Well man i think is kicking now i just did the same clip that i been doing now 4 2 friking days and the the change between Blur and sharp scenes it much much better so i think we cooking now we almost if not done. :wink:

PS: i just love this crop :lol:

boeddha 06-03-2003 04:38 PM

@ Girv

I don't know if you have already fixed your problem. But i got also a green bar at the bottom when i forgot to change the resize and addborders values when i started a new project. When i used the correct values (from moviestacker) the bar was gone.

@ Kwag

I used the script for avs 2.52 yesterday and everything was ok. But today I wanted to do some tests and the script doesn't work corect anymore. The color is messed up, so know i have blue people. Quite funny but it's not what I want. Do you have any idea what this can be? I am using your optimal script.

Thanks

kwag 06-03-2003 04:43 PM

Quote:

Originally Posted by boeddha
Quite funny but it's not what I want. Do you have any idea what this can be? I am using your optimal script.

Thanks

I don't have any idea (yet!), but I'm not stopping until I find out and get this right, no matter how many times I have to twist this script :!:
It's either a mathematical problem ( floating point error or something deep in the blur code ) of some other logical software control flow error.

-kwag

kwag 06-03-2003 04:46 PM

@ovg64 and all,

Make sure this line reads: FrameEvaluate("val = (lf / 16) + 0.05")
I forgot the "+" sign on the script above. I edited the script.

-kwag

ovg64 06-03-2003 05:15 PM

Yeah its Kool now, using the old adaptine script there was a part where actually the face was sharp and the mouth was a blur 8O :lol: , no more of that.


All times are GMT -5. The time now is 05:15 PM  —  vBulletin © Jelsoft Enterprises Ltd

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