Quantcast Avisynth: Mod to Not Blur Last Frame Prior to Scene Change? - digitalFAQ.com Forums [Archives]
  #1  
07-10-2003, 10:43 PM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Is there a very simple mod to the optimal script such that the last frame prior to a scene change is not blurred?

I started to code a secondary ConditionalFilter set with forward-looking YDifference state change detection and decided to ask here before I go through all of that.

I do realize how this affects quality at low bitrates.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
07-11-2003, 03:26 AM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
As we say in programing world : RTFM

You have a function called YDifferenceFromPrevious() that you can use insteed of YDifferenceToNext(). That's will make the bluring start just after the scene change, and not just before.
Reply With Quote
  #3  
07-12-2003, 07:26 PM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
I'm looking to have no blur which is a somewhat different beast.

Any idea how to accomplish that?

I mean, without a second ConditionalFilter to choose between the source and filtered streams?

Hmmm...another thought, getting rid of blurring altogether would also do this, wouldn't it?
Reply With Quote
  #4  
07-12-2003, 07:45 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
I suppose that a scene change lead to a big value for nf. So you can perhaps avoid the bluring when the value is upper than a MAX value (MAx has to be determined by some tests I guess)

If you don't want blur at all, try this :

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "((nf >= SwitchThreshold) && (nf < MAX)) ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")
Reply With Quote
  #5  
07-12-2003, 08:15 PM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
i got this advice using the script in vdubmod:

'i don't know what "MAX" means
{[Scriptclip],line 4}"

please, recomend the values for "max"
Reply With Quote
  #6  
07-12-2003, 08:24 PM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
Jorel READ MY POST !

I told that "MAX" have to be found by some tests.

Tests that I don't have the time to do because my PC is currently encoding a video (and it's 3:23am here ! )

I was just giving an idea, not a solution
Reply With Quote
  #7  
07-12-2003, 08:38 PM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
i read before ask Phil,
the dice is tumbling.....let me see.....

4...number 4
trying 4!


ps:
Phil,
as you can see,
your ideas are better than mine "solutions"
Reply With Quote
  #8  
07-12-2003, 08:40 PM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
For some reason, I'm having a similar problem.

SwitchThreshold and MAX don't seem to be recognized as variable names even though I'm declaring them as such. Odd.

MaxTreshold = 1.50
SwitchThreshold = 3
Max=5
nf = 0 # Current frame.

undot(c)
limiter()
asharp(1,4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.1))


# ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2 ? \
# unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
# TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "((nf >= SwitchThreshold) && (nf < MAX)) ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")
Reply With Quote
  #9  
07-12-2003, 08:45 PM
jorel jorel is offline
Invalid Email / Banned / Spammer
 
Join Date: Aug 2002
Location: Brasil - MG - third stone from the sun
Posts: 5,570
Thanks: 0
Thanked 0 Times in 0 Posts
i only change the word "max' in the script
to number 4 and the error is gone.

SwitchThreshold=(Width<=352)?4Width<=480)?3:2
ScriptClip("nf=YDifferenceToNext()"+chr(13)+"((nf> =SwitchThreshold)&&(nf<4))?\
unfilter(-(fmin(round(nf)*2,100)),-(fmin(round(nf)*2,100))):\
TemporalSoften(fmin(round(2/nf),6),round(1/nf),round(3/nf),1,1)")

maybe is right!
Reply With Quote
  #10  
07-12-2003, 09:02 PM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Still not working for me. I've put the filter into a function to apply it by field, not frame, and something isn't working. You are correct for standard script. Something isn't working properly with my modification. It reports SwitchThreshold has no value even though it is explicitly assigned inside the function. Grrr...

Cnr2("xxx",4,5,255)
ConvertToYV12()
even=SelectEven(SeparateFields()).KVCD_Filter()
odd=SelectOdd(SeparateFields()).KVCD_Filter()
Interleave(even,odd).Weave()
Limiter(min_luma=16)

##########################
#
# KVCD Filter - July 08, 2003
#
##########################

function KVCD_Filter(clip c){

MaxTreshold = 1.50
Max=5
nf = 0 # Current frame.

undot(c)
limiter()
asharp(1,4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.1))

# ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2 ? \
# unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
# TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

SwitchThreshold=(Width<=352)?4Width<=480)?3:2
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "((nf >= SwitchThreshold) && (nf < MAX)) ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

Limiter()

return last}

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
Reply With Quote
  #11  
07-13-2003, 08:51 AM
bman bman is offline
Free Member
 
Join Date: Apr 2002
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
Hi all
Maybe MAX is reserved word ???
Could be
Max and MAX are the same ???
bman
Reply With Quote
  #12  
07-13-2003, 02:05 PM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Well, I've found out it's an aspect of ConditionalFilter. Arguments passed to it must be declared as globals. In a strict grammar sense, that should not be the case. However, ConditonalFilter is doing things AviSynth really isn't designed for so it's "breaking" the normal grammar.
Reply With Quote
  #13  
07-14-2003, 04:30 AM
bman bman is offline
Free Member
 
Join Date: Apr 2002
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
@FredThompson
So , is your script working ???
Are u getting better results with this script ???
I'm curiouse
bman
Reply With Quote
  #14  
07-14-2003, 04:42 AM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
yes, it's working. I've removed the blur before a scene change. Right now I'm waiting for a 4:1:1 chroma filter to help fix some problems with saturated colors. Screenshots are at http://www.geocities.com/fredthompson6 The script posted there is old.
Reply With Quote
  #15  
07-14-2003, 06:52 AM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@FredThompson,

What do your working non-blur script look like? And do you get smaller files without the blur?
__________________
AudioSlave
Reply With Quote
  #16  
07-15-2003, 05:07 AM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
I guess "better" is a personal opinion

Full script should be up within a day or so. I got sidetracked with wavelet noise compression and have also played with Shadow Smoother for near-black smoothing. Also worked with Xesdeeni's 411Helper to help remove some artifacts. Waiting on an answer wrt BorderControl.

I don't use the Sansgrip cropping/resizing stuff.

Script is field-based for interlaced material, not progressive.

You can try the script yourself soon enough.
Reply With Quote
  #17  
07-15-2003, 05:12 AM
audioslave audioslave is offline
Free Member
 
Join Date: Mar 2003
Location: Sweden
Posts: 725
Thanks: 0
Thanked 0 Times in 0 Posts
@FredThompson,

Looking forward to see and test your script! Hurry please!
__________________
AudioSlave
Reply With Quote
  #18  
07-16-2003, 03:19 AM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
ok, the site is updated

http://www.geocities.com/fredthompson6

Something went bad wrong because there is some blurring that shouldn't be there. It should be fixed fairly soon. It's 4 AM and I'm pooped

Take a look at how the saturated red and near-blacks were handled. Trying to track down a problem with how AviSynth parses lines ate up 4 hours and I'm not going to stay up trying to fix the script.

cropping and border are hardcoded. Lots of variables, including those, will be pulled out soon enough.

I haven't tested enough to know if the double Shadow Smoother is causing the problems or not.
Reply With Quote
  #19  
07-16-2003, 04:04 AM
Dialhot Dialhot is offline
Free Member
 
Join Date: May 2003
Posts: 10,463
Thanks: 0
Thanked 0 Times in 0 Posts
A little remark : you have all your avs filters in the plugin directory of avs2.52. So you do not need any "LoadPlugin" line in your script : avs2.52 has an autoload feature.

Other : you start by a "ConvertToYUY2" followed by a "ConvertToYV12" (with cnr2 used between the two) : don't you have a chroma noise reducer usable in YV12 ?

All these colorspace changes kill your chroma and I'm sure it's not your purpose
Reply With Quote
  #20  
07-16-2003, 04:19 AM
FredThompson FredThompson is offline
Free Member
 
Join Date: Jun 2003
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
yes, I know. The intent is to build a modular script collection such that all the details are hidden.

Shadow Smoother forces me to have RGB at some point because it's a VirtualDub filter. DarkSmoother performs better and is AviSynth but very slow.

Pops is also RGB and limiter isn't. I do need to pay more attention to color but the first focus was to get rid of near-black swim and such. I think that is being handled ok except I don't know why it's now too smooth. I was playing around with putting all the filtering inside the field split and messed something up when I tried to put them back to the original locations. Xesdeenis' lines mix modes on purpose. I also can't replicate his results and doom9's forum is down right now.

I know it's a mess right now. The focus was on noise reduction first and I'll start tiddying up the colorspace issues afterwards.

I'm VERY open to colorspace suggestions. That's the next step, I think. Well, maybe a little WarpSharp if that's the only way to clean up the over emphasis of brights. Look at the camcorder screenshots and you'll see it in the smoke and their skin. I know Shadow Smoother needs tuning. I suspect the Xesdeeni lines are screwing it all up. His samples showed proper removal of 4:1:1 but I've got blockiness.

I'm also too tired to think coherently. Thanks for the resonse. Lemme know if you see glaring problems or have replacement ideas.
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Avisynth: Dynamic Linear Adaptive Filtering and Scene Change Detection supermule Avisynth Scripting 3 09-15-2006 01:45 AM
Avisynth: Scene Change Detection? Prodater64 Avisynth Scripting 1 02-29-2004 09:05 PM
Avisynth: Adding scene change blur to static script? audioslave Avisynth Scripting 7 11-02-2003 11:23 PM
Avisynth: Detect scene change and TemporalCleaner ? NismoSX Avisynth Scripting 4 07-19-2003 12:20 PM
Avisynth: I can see the blur on scene changes! audi2honda Avisynth Scripting 11 07-08-2003 09:46 PM

Thread Tools



 
All times are GMT -5. The time now is 04:26 PM  —  vBulletin Jelsoft Enterprises Ltd