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 2nd April 2020, 14:55   #1  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
Autolevels and full black frames

Hi all,

I'm trying to use autolevels() and I'm running into an issue where it's causing pure black frames that exist in my video to go all funky colored.
(see attachment)

Is there a parameter I'm missing that can act as a threshold so it's doesn't try to do it's magic on pure black frames?
Attached Images
 
frubsen is offline   Reply With Quote
Old 2nd April 2020, 15:24   #2  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Maybe the coring option can be useful here.
videoh is offline   Reply With Quote
Old 2nd April 2020, 17:18   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
What version AutoLevels ?
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 2nd April 2020, 18:19   #4  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
using 0.10
frubsen is offline   Reply With Quote
Old 2nd April 2020, 18:56   #5  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
ahhh, think i figured it out. I needed to have ConvertToRGB24() before autolevels. That seemed to fix the issue.

edit-hmm but then that seems to cause some issues in other places with blacks getting crushed....weird

I'm using
autolevels(output_low=6, output_high=235)

Last edited by frubsen; 2nd April 2020 at 19:03.
frubsen is offline   Reply With Quote
Old 2nd April 2020, 19:18   #6  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
This is my script

Code:
SetMemoryMax(800)
LSMASHVideoSource("X:\Reels_10-18.mov")
converttoyv12()
Crop(146, 2, -146, -2)
removedirtmc(50)
converttorgb24()
autolevels(output_low=6, output_high=235)
converttoyv12()
ColorYUV(autowhite=true)
LanczosResize(662, 480)
Sharpen(0.3)
You can see the difference when I use ConverttoRGB24() and without it in this scene. It's a very underexposed clip to begin with, I just find it odd how changing the colorspace really affects how autolevels works.
Attached Images
  
frubsen is offline   Reply With Quote
Old 2nd April 2020, 23:51   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
autolevels(output_low=6, output_high=235)
Maybe should be 16 NOT 6. # 16 and 235 are defaults for YUV.

Try this one here:- http://www.mediafire.com/file/8k2vub...90711.zip/file

Maybe use something like this
Code:
AL_IGNORE_LO   = 1.0/4096
AL_IGNORE_HI   = AL_IGNORE_LO
AL_RADIUS      = 12
AL_SC2TH       = 8
AL_SC2PERC     = 100.0/3
AL_MINRNG      = 100


SetMemoryMax(800)
LSMASHVideoSource("X:\Reels_10-18.mov")
converttoyv12()
Crop(146, 2, -146, -2)
removedirtmc(50)

AutoLevels(FilterRadius=AL_RADIUS,ignore_low=AL_IGNORE_LO,ignore_high=AL_IGNORE_HI,
    \ sc2Th=AL_SC2TH,sc2Perc=AL_SC2PERC,MinRng=AL_MINRNG)

ColorYUV(autowhite=true)
LanczosResize(662, 480)
Sharpen(0.3)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 2nd April 2020 at 23:56.
StainlessS is offline   Reply With Quote
Old 3rd April 2020, 16:27   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Now I've seen your frame (well modified frames)

Maybe start with something like this, but I dont really have any idea what you are expecting to get out of it.

Using the previously linked dll
Code:
/*

Autolevels(clip c,
           int      "filterRadius"      = 7,                 [* Original plugin = 5 *]
           int      "sceneChgThresh"    = 20,
           string   "frameOverrides"    = "",
           float    "gamma"             = 1.0,               [* Auto if autogamma *]
           bool     "autogamma"         = false,
           float    "midpoint"          = 0.5,
           bool     "autolevel"         = true,
           int      "input_low"         = undefined,         [* measured by statistics   *]
           int      "input_high"        = undefined,         [* measured by statistics   *]
           int      "output_low"        = (c.IsYUV)?16 :0,   [* 16 for yuv, 0 for rgb    *]
           int      "output_high",      = (c.IsYUV)?235:255  [* 235 for yuv, 255 for rgb *]
           bool     "coring"            = false,
           float    "ignore"            = 1.0/256.0,
           float    "ignore_low"        = ignore,
           float    "ignore_high"       = ignore,
           int      "border"            = 0,
           int      "border_l"          = border,
           int      "border_r"          = border,
           int      "border_t"          = border,
           int      "border_b"          = border,
           bool     "debug"             = false

           [* Additional to original args *]

           int      "sc2th"             = 12
           Float    "sc2Perc"           = 33.33               [* Where scene change via sceneChgThresh, and % of pixels different by at least sc2th is less than sc2Perc, then Override to NOT scene change *]
           Float    "GamMax"            = 1.5                 [* Max limit on Gamma correct *]
           Float    "GamMin"            = 1.0/GamMax          [* Min limit on Gamma correct *]
           int      "minRng"            = 100                 [* If dynamic range of luma is less than minRng then corrections are reduced *]
        )

*/


LoadPlugin(".\ImageSeq.dll")

AUTOGAMMA   = True
MIDPOINT    = 0.45
IGNORE_LO   = 1.0/512
IGNORE_HI   = IGNORE_LO
###
SC2TH       = 12
SC2PERC     = 100.0/3
GAMMAX      = 2.0                       # Limit gamma correction
GAMMIN      = 1.0/GAMMAX                #   Ditto
MINRNG      = 110

Imagesource(".\without rgb24.jpg")
Crop(0,0,Width/4*4,height/4*4)          # Mod 4
converttoyv12()
ORG=Last

AutoLevels(autogamma=AUTOGAMMA,MidPoint=MIDPOINT,ignore_low=IGNORE_LO,ignore_high=IGNORE_HI,
    \ sc2Th=SC2TH,sc2Perc=SC2PERC,gammax=GAMMAX,gammin=GAMMIN,MinRng=MINRNG)

#ColorYUV(autowhite=true)

Stackhorizontal(ORG,Last)


It dont look too good (but you got the source frame, I dont, also v0.10 is I think original AutoLevels just recompiled).
EDIT: Above using just gamma, plenty of both black and white already in your modded frames.
Above image, gamma is almost certainly being limited by GamMax as MidPoint would make way too bright.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 3rd April 2020 at 16:41.
StainlessS is offline   Reply With Quote
Old 4th April 2020, 17:41   #9  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
Thanks StainlessS, ended up using your first script and it worked out pretty well.
frubsen is offline   Reply With Quote
Old 4th April 2020, 19:42   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Good.
I'm kinda curious, can you post same frame again, before and after.

You can also turn off AUTOGAMMA in 2nd script and also play with other args.
Maybe make IGNORE_LO = 1.0/4096 # 1.0/512

EDIT: You can upload images on PostImage.org without an account, and post links here.
(Use hotlink for forum, or thumbnail for forum.)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 4th April 2020 at 19:53.
StainlessS is offline   Reply With Quote
Old 5th April 2020, 13:03   #11  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
when converting YUV -> RGB -> YUV don't forget to set the correct matrix:

Code:
converttorgb24(matrix="PC.601")   Y=0 becomes R=G=B=0 
yourfiltershere()
converttoyv12(matrix="PC.601")  R=G=B=0 becomes Y=0
Code:
converttorgb24(matrix="PC.601")   Y=0 becomes R=G=B=0 
yourfiltershere()
converttoyv12()  R=G=B=0 becomes Y=16
Code:
converttorgb24()   Y=16 becomes R=G=B=0 (everything below Y=16 and above Y=235 will be clipped!)
yourfiltershere()
converttoyv12()  R=G=B=0 becomes Y=16
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 5th April 2020, 18:45   #12  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
before


after
frubsen is offline   Reply With Quote
Old 5th April 2020, 18:51   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thanks very much, I'm quite amazed that it does as well as that.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 5th April 2020, 18:56   #14  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
Yeah it worked really well, very happy with it, thanks!
frubsen is offline   Reply With Quote
Old 5th April 2020, 19:03   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Did you try AutoGain ?

EDIT: I meant AutoAdjust.

AutoAdjust is a bit darker.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 5th April 2020 at 19:12.
StainlessS is offline   Reply With Quote
Old 7th April 2020, 14:58   #16  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
I did not try autoadjust on that clip

I have some new under exposed clips I'm going to play around with soon and will give both a shot.
frubsen is offline   Reply With Quote
Old 12th April 2020, 19:08   #17  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
So I'm running into another issue with flickering brightness levels using autolevels 0.12.

Here is the script I'm using

Code:
AL_IGNORE_LO   = 1/4096
AL_IGNORE_HI   = AL_IGNORE_LO
AL_RADIUS      = 12
AL_SC2TH       = 4
AL_SC2PERC     = 100.0/3
AL_MINRNG      = 100


SetMemoryMax(800)
ImageSource("Reel_4.720p_%05d.png", start =4,end=3592,fps=18)
audiodub(BlankClip(audio_rate=48000, stereo = true, length = 3589, fps=18))
converttoyv12()
Crop(140, 4, -140, -4)
removedirtmc(40)
AutoLevels(FilterRadius=AL_RADIUS,ignore_low=AL_IGNORE_LO,ignore_high=AL_IGNORE_HI, sc2Th=AL_SC2TH,sc2Perc=AL_SC2PERC,MinRng=AL_MINRNG)
Tweak(sat=1.1)
LanczosResize(676, 480)
sharpen(0.2)
And here the sample of what it's doing

https://www.mediafire.com/file/weku8...icker.mp4/file

edit: looks like it's the AL_IGNORE_HIGH value which is causing the differing levels...now what to set it to...

Last edited by frubsen; 12th April 2020 at 19:31.
frubsen is offline   Reply With Quote
Old 12th April 2020, 20:13   #18  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Ignore by default in original was 1.0/256.0, I changed to 1.0/512.0,
1.0/4096 was intended specific for your dark clip [I did not want it to ignore too much, 0.0 would have been a good choice too maybe].

I want to get back to this plug, wanna add DC detect clip, where can denoise/blur DC, and stats taken from that instead of source.
Try above two mentioned Ignore settings, see what happens.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 13th April 2020 at 11:48.
StainlessS is offline   Reply With Quote
Old 13th April 2020, 00:14   #19  |  Link
frubsen
Registered User
 
Join Date: Jul 2004
Posts: 98
I ended up just going back to autolevels(output_low=16, output_high=235) and it fixed the issue.
frubsen is offline   Reply With Quote
Old 13th April 2020, 11:36   #20  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
You could try this (req RT_Stats)
https://forum.doom9.org/showthread.p...61#post1757661

Does a scan of SAMPLES Frames of a clip detecting min and max luma for those samples (default 40 samples),
then stretches luma range using Levels() for entire clip.
There should be no flickering at all, unless already in source clip.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 13th April 2020 at 11:39.
StainlessS 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 01:47.


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