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 Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th September 2009, 19:37   #1  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
SoftSharpen 8.2 - avisynth script

Hello.

I try to develop an avisynth script: SoftSharpen. The main idea consists to apply different effects on different areas of a picture: sharpening static areas, blurring motion, temporal and spatial denoising. With this strategy, SoftSharpen tries to preserve the compressibility of the video.

Some other processings are also implemented: deringing, debanding, deblocking, and an experimental antialiasing.

SoftSharpen is provided with some presets ("film","light","anim","vhs",...) in order to use the script easily. Some examples:
All options of SoftSharpen (except debanding and deblocking) are compatible with avisynth MT : use setMTmode(2,0).

Code:
SoftSharpen(Video, "Blur", "Sharp", "DeNois", "DeNoisT", "Move", "DeBan", "DeRin", "DeBl", "AA", "Overlap", "dct", 
                           "Preset", "Fast", "Width", "Height", "Verbose", "Show")


Video.SoftSharpen() # medium process
Video.SoftSharpen(preset="film") # my favorite process
Video.SoftSharpen(preset="light") # weak process
Video.SoftSharpen(preset="vhs") # stronger process
Video.SoftSharpen(show=true) # to see detected areas on screen
Of course, some filters are required: MSharpen, ASharp, BlindPP (exported from DGDecode or mpeg2dec3 for example), Deen, GradFun2db (only for debanding), RemoveGrain, DCTFilter, MaskTools (v1 or better v2), and MVTools2.
All these filters (and many others!) can be downloaded from http://avisynth.org/mediawiki/External_filters or http://avisynth.org/warpenterprises .

If someone makes time to test it quickly, I would be happy to have his/her comments to improve this script (a "read me" file is included in the zip file).
Thanks

Download : click on this Link to obtain the last version


ChangeLog
version 7.8
new option Line (integer between 0 and 255) increases dark in lines. Useful especialy for anim. By default, Line=0 (no process)

version 7.7
minor modification of Sharp

versions 7.4 , 7.5 , 7.6
Optimised sharpening process.
The type of Sharp has changed (float now).

version 7.3
Optimization of the preset "light" (denoising & speed)

version 7.2
The type of DebrT has changed (float now).

version 7.1
RemoveGrain (mode 1, 2 or 27) is used for spatial denoising.

version 7.0
New option "Overlap" for a better compatibility with MDegrain[1,2,3] and AviSynth MT.

version 6.9
Experimental antialiasing (not perfect, but very fast)
Fixed a bug when "Sharp=0" in version 6.8

version 6.8
Faster debanding.
Less constraint on the resolution: now, needs only mod4.
Optimised sharpening process.

version 6.7
Changed the "anim" preset (slower but better).
Now, use of UnDot at the end of the script.
Some optimizations.

version 6.6
Changed the blurring process: now, it is less destructor, but always efficient.

version 6.5
Fixed a bug when "fast=true". Anyway, prefer "fast=false" (except for anim perhaps).

Last edited by leon1789; 20th January 2012 at 13:47. Reason: new version
leon1789 is offline   Reply With Quote
Old 7th September 2009, 20:39   #2  |  Link
BigDid
Actually in reserve
 
Join Date: Oct 2004
Posts: 1,605
Hi and welcome to the forum Leon,

I am glad you finally made it to doom9

If a mod could examine and approve the attachment file (1 avsi file + 1 or 2 readme) thanks.
If not, I suppose Leon could post the script of the avsi as quoted text to get things started.

I have used this multi-usage script (older french revs) for a quite a while with good results.
Presets is to get started, but any param can be tuned separately for desired results.

Did
__________________
Having a problem with AutoGK? Read & use the FAQ & MORE FAQ first
Want to exchange on AutoGK? try doom10.org
In reserve (inactive) for an undefined period of time.

Last edited by BigDid; 10th September 2009 at 18:21. Reason: Alternate link integrated in 1st post
BigDid is offline   Reply With Quote
Old 8th September 2009, 13:38   #3  |  Link
buzzqw
HDConvertToX author
 
Join Date: Nov 2003
Location: Cesena,Italy
Posts: 6,552
could you post some screenshots of this filter at work ?

BHH
__________________
HDConvertToX: your tool for BD backup
MultiX264: The quick gui for x264
AutoMen: The Mencoder GUI
AutoWebM: supporting WebM/VP8
buzzqw is offline   Reply With Quote
Old 8th September 2009, 17:31   #4  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
Quote:
Originally Posted by buzzqw View Post
could you post some screenshots of this filter at work ?

BHH
Of course, here two images.

The first shows a car moving quickly: in fact, on the video, the car is almost motionless, but the background moves much. So the cars (in green) is sharpened and the background blurred (in blue).


On the second image, an object moves, and man and flower are motionless. So the object is blurred (in blue) and the men and flower are sharpened (in green). (Denoising is red)

Last edited by leon1789; 8th September 2009 at 18:15.
leon1789 is offline   Reply With Quote
Old 8th September 2009, 18:04   #5  |  Link
BigDid
Actually in reserve
 
Join Date: Oct 2004
Posts: 1,605
Hi Buzz,

The blur effect can be disturbing but very useful to raise compressability, like for a 2 pass encode.
It can be disabled by using softsharpen(blur=0)

If you look at the car and the roof picture, you loose details on the roof because the effects of softsharpen(), without presets or params, are quite strong.
You get them with softsharpen(verbose=true):
Blur 21
Sharp 20
Spatial and Temporal denoising 7
Deringing 4
Movement detection 41

On this source you could adjust the blur to a lower level, Ex: blur=12 (only on motion/moving parts) and/or the denoising like Denois=3 (all parts of the source needing denoising as analysed by/for Mdegrain) to regain details on the roof but loose some compressibility.

Preset="film" or Preset="light" are good starting points and you can use estimsoftsharpen() on a small part (comptest) to compute a more precise sharp level

Did
__________________
Having a problem with AutoGK? Read & use the FAQ & MORE FAQ first
Want to exchange on AutoGK? try doom10.org
In reserve (inactive) for an undefined period of time.

Last edited by BigDid; 8th September 2009 at 18:15. Reason: Oops, older rev, params missing
BigDid is offline   Reply With Quote
Old 8th September 2009, 18:14   #6  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
Yes, that's it BigDid !
leon1789 is offline   Reply With Quote
Old 10th September 2009, 00:05   #7  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,687
Wow, very cool. Thanks for the new script! I'll have to try this out on a couple of encodes. Wonder what the speed is like...

Edit: Okay, um... how does EstimSoftSharpen() work? I just insert it and wait for my estimsoftsharpen.txt file, correct? I'm not getting any text file.
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo

Last edited by Adub; 10th September 2009 at 00:27.
Adub is offline   Reply With Quote
Old 10th September 2009, 00:29   #8  |  Link
BigDid
Actually in reserve
 
Join Date: Oct 2004
Posts: 1,605
Quote:
Originally Posted by Adub View Post
...Wonder what the speed is like...
Hi Adub,

It is fair, I suppose because the filters/functions used like: Deen, Msharpen, BlindPP or gradfun2b are less sophisticated than in the big scripts.

Therefore the usage is more suited for conventionals sources and less for "extreme" restoring . Hey, who does restore the Startrek1,2 or 3 everyday?
Anyhow, give it a try you could have good surprises

It can even be full MT with some tweaks if interested

Did

PS: Note to Leon1789; bug with the preset "anim" in the 6.4 rev; enter parameters manually if needed until bugfix. Preset "anim" has the following parameters:
Blur 21 - Sharp 15 - Derin 3 - Move 38 -Denois 10 - DenoisT 10 - Deban 2 - debl 0

PS2: Estimsoftsharpen() needs an encode to trigger the text file, use a short length or a SelectRangeEvery()
__________________
Having a problem with AutoGK? Read & use the FAQ & MORE FAQ first
Want to exchange on AutoGK? try doom10.org
In reserve (inactive) for an undefined period of time.

Last edited by BigDid; 10th September 2009 at 01:25. Reason: anim parameters
BigDid is offline   Reply With Quote
Old 10th September 2009, 01:27   #9  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,412
Quote:
Originally Posted by leon1789 View Post
If someone takes time to test quickly, I would be happy to have his/her comments to improve this script
I haven't tried actually running it, but this sequence looks wrong:
Code:
  VB = Fast ? nop : Super.MAnalyse(isb=true, blksize=blk, TrueMotion=true)
  ...
  Video1 = Video0.MDegrain1(Super, VB, VF, thSAD=DeNoisT*50)
When Fast is true, won't this give an invalid argument to MDegrain1?
Gavino is offline   Reply With Quote
Old 10th September 2009, 06:51   #10  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
It would be safer to do:

Code:
VB = Super.MAnalyse(...)
...
Video1 = Fast ? Video0.MDegrain(...) : Video0
if Fast is false, then MDegrain is never evaluated and therefore VB never needs to be created. otoh, you would get an empty parameter for the backward vector (VB) in MDegrain1 and it'd probably throw an error.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 10th September 2009, 09:24   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,412
Quote:
Originally Posted by Sagekilla View Post
Code:
Video1 = Fast ? Video0.MDegrain(...) : Video0
You've got that the wrong way round. It should be
Video1 = Fast ? Video0 : Video0.MDegrain(...)

Quote:
you would get an empty parameter for the backward vector (VB) in MDegrain1 and it'd probably throw an error.
nop isn't an empty parameter, it's just zero in disguise! (See this thread.)
So it will throw a type mismatch when used as a vector clip.
Gavino is offline   Reply With Quote
Old 10th September 2009, 18:05   #12  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
Thanks to Gavino, BigDid and Sagekilla: I'm so sorry for this enormous idiot mistake
I change the version -> 6.5 now

Last edited by leon1789; 10th September 2009 at 22:11.
leon1789 is offline   Reply With Quote
Old 10th September 2009, 18:23   #13  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
Quote:
Originally Posted by Adub View Post
Edit: Okay, um... how does EstimSoftSharpen() work? I just insert it and wait for my estimsoftsharpen.txt file, correct? I'm not getting any text file.
EstimSoftSharpen is a minor function: it measures the motion of the video. The result (a candidat number for the "sharp" parameter) is readable in the EstimSoftSharpen.txt file after a real execution of the script on (a part of) the video, for example after an encode as BigDid said.
leon1789 is offline   Reply With Quote
Old 11th September 2009, 00:25   #14  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,687
Okay, that's dandy, I had no trouble understanding what it did, but my EstimSoftSharpen.txt file is not being created. Both after playing and encoding.

Script:
Quote:
SetMTmode(2)
DGDecode_mpeg2source("C:\samples\Elektra_Sample.d2v", info=3)
ColorMatrix(hints=true, interlaced=true, threads=0)
tfm(order=0).tdecimate()
Estimsoftsharpen()
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo
Adub is offline   Reply With Quote
Old 11th September 2009, 01:19   #15  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,412
Have you tried searching in other folders?
It should be created in the working folder of whatever player/encoder you used.
Gavino is offline   Reply With Quote
Old 11th September 2009, 01:24   #16  |  Link
BigDid
Actually in reserve
 
Join Date: Oct 2004
Posts: 1,605
Hi Adub,

Sorry about that. I re-checked with the new rev, no problem here with XP-SP3.
Conditions: Vdubmod, short xvid encode with a selectrangeevery()

It should be created in the directory where your encode file will take place (xxx.avi or .other).

You may want to make a search; exact spelling is "EstimSoftSharpen.txt"

Is your script using a mod 16 source?

Did
__________________
Having a problem with AutoGK? Read & use the FAQ & MORE FAQ first
Want to exchange on AutoGK? try doom10.org
In reserve (inactive) for an undefined period of time.

Last edited by BigDid; 11th September 2009 at 02:11.
BigDid is offline   Reply With Quote
Old 12th September 2009, 20:06   #17  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
Quote:
Originally Posted by BigDid View Post
The blur effect can be disturbing but very useful to raise compressability (...)
That's true. So the blurring process has been modified in order to be less destructive (but always useful to raise compressibility, I think).
I change the version -> 6.6 now

Last edited by leon1789; 12th September 2009 at 20:12.
leon1789 is offline   Reply With Quote
Old 15th September 2009, 07:43   #18  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,412
Taking another look at this, I can suggest a couple of minor coding changes (optional, the existing code 'works'):
Code:
function Diff(clip vid, clip v1, clip v2, string color)
...
  b = Eval("BlankClip(vid, color=" + color + ")")
Why not make color an int, and call BlankClip directly, without Eval?
You can pass $0000FF, etc, directly to the function as valid int literals.
Code:
  Masq = Video.ScriptClip(""" WriteFile("EstimSoftSharpen.txt", \
                          Round(13+Net/6).string, append=false) """)
You don't need to put WriteFile inside ScriptClip, as it is itself already a 'run-time' filter. You could just write:
Code:
  Masq = Video.WriteFile("EstimSoftSharpen.txt", \
                         "Round(13+Net/6)", append=false)
Gavino is offline   Reply With Quote
Old 15th September 2009, 08:07   #19  |  Link
buzzqw
HDConvertToX author
 
Join Date: Nov 2003
Location: Cesena,Italy
Posts: 6,552
@leon1789

i would like to include your filter in my HDConvertToX package

could i add it ?

i think about adding at max 2 preset,

SoftSharpen()
SoftSharpen(preset="film")

would you suggest something different ?

BHH
__________________
HDConvertToX: your tool for BD backup
MultiX264: The quick gui for x264
AutoMen: The Mencoder GUI
AutoWebM: supporting WebM/VP8
buzzqw is offline   Reply With Quote
Old 15th September 2009, 10:15   #20  |  Link
leon1789
Registered User
 
leon1789's Avatar
 
Join Date: Sep 2009
Location: Poitiers (Fr)
Posts: 77
Quote:
Originally Posted by buzzqw View Post
@leon1789
i would like to include your filter in my HDConvertToX package
could i add it ?

i think about adding at max 2 preset,

SoftSharpen()
SoftSharpen(preset="film")

would you suggest something different ?

BHH
No problem: include the filter

For preset, I suggest SoftSharpen(preset="film") and SoftSharpen(preset="light"),
because spatial denoising is strong with SoftSharpen().

Last edited by leon1789; 15th September 2009 at 10:46.
leon1789 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:48.


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