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 25th October 2018, 15:11   #21  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Here from Colors_RGB.avsi
https://forum.doom9.org/showthread.p...75#post1741775





Same from Wiki:- http://avisynth.nl/index.php?title=C...ets&oldid=3718
EDIT: Above link NOTE:- by clicking on the column header, the table will sort by that column.
__________________
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; 25th October 2018 at 15:20.
StainlessS is offline   Reply With Quote
Old 25th October 2018, 17:19   #22  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
Ah, I did have the requiered dll, but I didn't have Avisynth+, I thought I had that one but I got Avisynth 2.6, uninstalled and installed Avisynth+ and it worked like a charm. And it was so mutch easier now. Better system than I wanted at the beginning. It feels like magic.

Oh, and I wanted fix strength, I did edit my answer when I realised I forgott to answer, but it didn't update my post somehow.


I love it! Looks great! I am following the "traditional" tinting colors from kino that was avalible in the 30's. So I stick to my colors, but Its great that I can use the Colors_RGB.avsi also. The only thing I want to add is two colors, like the darker should be red and the lighter should be orange (like inferno should be). If its hard to fix its no problem. I'm happy you made my day so mutch easier.

From the script:



A little bit extreme but I want also something like this if its possible:

__________________
Automatic Colorization

Last edited by color; 25th October 2018 at 18:14.
color is offline   Reply With Quote
Old 26th October 2018, 07:10   #23  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
Quote:
Originally Posted by color View Post
Ah, I did have the requiered dll, but I didn't have Avisynth+, I thought I had that one but I got Avisynth 2.6, uninstalled and installed Avisynth+ and it worked like a charm. And it was so mutch easier now. Better system than I wanted at the beginning. It feels like magic.
By installing AviSynth+ you have also solved the compatibility problem with my script. However, it won't work with the old AviSynth+ from avs-plus.net nor with the latest release r2728 by pinterf due to an error in Expr. It works out-of-the-box, for example, with the next-to-last release r2664 at https://github.com/pinterf/AviSynthP...s/tag/r2664-MT

Quote:
Originally Posted by color View Post

A little bit extreme but I want also something like this if its possible:

https://preview.ibb.co/gMKT1V/Kino-Script000006.png
It wouldn't be difficult at all to implement this into my filter but I'm very busy at the moment. I could try this weekend, but StainlessS will probably have already found a solution by then

Last edited by magiblot; 26th October 2018 at 07:30.
magiblot is offline   Reply With Quote
Old 26th October 2018, 07:40   #24  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
I hope they fix that in the next release of avisynth, btw, stupid question. I read a little bit about vaporsynth, might that work similar like avisynth or does it miss/not contain important scripts? I did got virtualdub to work in ubuntu and vaporsynth also, but not avisynth and not avisynth+. Well If I do a little bit more digging maybe.

I don't know but I tried yours also, I do like both, but StainlessS's (look att al the S) is a little bit easier.

Its a bit extreem, but I looked on how the dyed films had for colors and some colors are just not the same on both. Some where dyed film and after it was developed it was dyed again that only effected the dark parts. Not all but a few colors.
__________________
Automatic Colorization
color is offline   Reply With Quote
Old 26th October 2018, 08:04   #25  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
Quote:
Originally Posted by color View Post
I hope they fix that in the next release of avisynth, btw, stupid question. I read a little bit about vaporsynth, might that work similar like avisynth or does it miss/not contain important scripts? I did got virtualdub to work in ubuntu and vaporsynth also, but not avisynth and not avisynth+. Well If I do a little bit more digging maybe.
I have barely used VapourSynth, so I can't give you advice on it. However, I managed to get AviSynth+ working on Linux. It worked for me when using the "-with-vc_redist" installer. That is, of course, using Wine. I do not remember doing any specific tweaks to get it working. Well, I also installed K-Lite Codec Pack just in case.

Also, make sure you are using the updated branch of VirtualDub called VirtualDub2: https://sourceforge.net/projects/vdfiltermod/
magiblot is offline   Reply With Quote
Old 26th October 2018, 09:18   #26  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
K-Lite Codec Pack works perfect, what "system" version do you use in Wine/PlayonLinux (sorry for the o.t.) I use VirtualDub2 (sadly does not want to export png frame serie, bug?) and a modified version of VirtualDub 1.10.4 with "large adress aware" for exporting 1080p or bigger. Both works in PlayonLinux. I will give it a try with the package "-with-vc_redist".
__________________
Automatic Colorization
color is offline   Reply With Quote
Old 26th October 2018, 19:01   #27  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
Quote:
Originally Posted by color View Post
K-Lite Codec Pack works perfect, what "system" version do you use in Wine/PlayonLinux
Windows 7 64-bit. But I don't use PlayOnLinux, I just have AviSynth and friends installed on the default wineprefix. I don't think the trick is in these settings though -- we'll see how it goes after you try the installer I said.
magiblot is offline   Reply With Quote
Old 26th October 2018, 22:40   #28  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by magiblot View Post
It wouldn't be difficult at all to implement this into my filter but I'm very busy at the moment. I could try this weekend, but StainlessS will probably have already found a solution by then
Not ruddy likely, at least you seem to have some idea what you are doing (whereas I dont have a clue how to do that) so I'll wait along with Color to see what you come up with.
__________________
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 26th October 2018, 23:19   #29  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
Okay, I gave it a try, I don't know if this is what you are looking for. I made it as a separate function since I believe it does something very different.

Example:

Code:
#https://www.welovepuzzle.ro/81759/puzzle-grafika-vintage-1000-piese-53507.jpg
ImageSource("puzzle-grafika-vintage-1000-piese-53507.jpg",end=0)
margin = width/16
AddBorders(margin,0,margin,0,$191919)
Spline64Resize(2*width/3,2*height/3)
ConvertToY(matrix="Rec601")
HSLtint(hue=36, sat=1.0, hueRange=240, satRange=1.0)
ColorMask(0.15, $1A08B3)


Code:
# ColorMask rev. 20181027 by magiblot1
function ColorMask(clip c, float "threshold", int "color", bool "invert", string "matrix") {
    # Replaces part of the picture by a plain color, based on the source's brightness.
    # "threshold" is a float in the range [0 .. 1] that specifies the brightness
    # up to which the color mask is applied. It can be done the other way round
    # by setting invert=true. 0 stands for absolute dark and 1 for pure white.
    # "color" specifies the color to be applied, e.g. $000000 for black.
    # YUV sources are expected to be TV range, RGB full range.
    # Requires masktools2 and AviSynth+ by pinterf
    
    Assert(0 <= threshold <= 1, """ColorMask: "threshold" must be in the range [0.0 .. 1.0].""")
    Assert(c.BitsPerComponent == 8, "ColorMask: This filter does not support high bit depth.")

    invert = Default(invert, false)
    matrix = Default(matrix, c.Width() > 1100 || c.Height() > 600 ? "Rec709" : "Rec601")
    
    y = c.IsRGB() ? c.ConvertToY(matrix=matrix).ColorYUV(levels="TV->PC") : c.ConvertToY().ColorYUV(levels="TV->PC")
    mask = mt_lut(y, String(threshold*255)+" x > "+(invert ? "0 255" : "255 0")+" ?").mt_deflate(threshold*255)
    mask = c.IsRGB() ? mask.CombinePlanes("RGB","YYY",pixel_type="RGBP8") : mask.CombinePlanes("YUV","YYY",pixel_type="YUV444P8")
    
    color = BlankClip(c,pixel_type="RGB32",color=color)
    color = c.IsRGB() ? color.ConvertToPlanarRGB() : color.ConvertToYUV444(matrix=matrix)
    
    p = c.IsRGB() ? c.ConvertToPlanarRGB() : c.ConvertToYUV444()
    
    merged = mt_merge(p,color,mask,U=3,V=3)

    return c.IsRGB32() ? merged.ConvertToRGB32()
    \ :    c.IsRGB24() ? merged.ConvertToRGB24()
    \ :    merged
        
}

Last edited by magiblot; 28th October 2018 at 17:11.
magiblot is offline   Reply With Quote
Old 27th October 2018, 08:54   #30  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
I was trying to test this with a small clip, but I get "Input and output need to have the same number of planes".

EDIT: I did try out the latest Avisynth+ for another script later last night. So that might be why, just forgotten it...I will try the new one with the hotfix instead.

EDIT 2: I had to "LoadPlugin("C:\Program Files (x86)\AviSynth+\plugins64\masktools2.dll")", but now I get this result with your script, wierd:

__________________
Automatic Colorization

Last edited by color; 27th October 2018 at 09:58.
color is offline   Reply With Quote
Old 27th October 2018, 15:22   #31  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
Quote:
Originally Posted by color View Post
EDIT: I did try out the latest Avisynth+ for another script later last night. So that might be why, just forgotten it...I will try the new one with the hotfix instead.
EDIT: I updated the function in post #17, just set the parameter oldAvsPlus=false when using HSLTint.

The reason why is that r2728 changed the order of the parameters of Expr but also broke compatibility with my use case. It works with the hotfix build but Expr now expects processing settings in the order R-G-B, while it used the order G-B-R in older versions.

Last edited by magiblot; 27th October 2018 at 15:43.
magiblot is offline   Reply With Quote
Old 27th October 2018, 22:06   #32  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
Oh. I will. Thank you.

I got what I needed. Thank you both so mutch!
__________________
Automatic Colorization
color is offline   Reply With Quote
Old 11th June 2021, 20:38   #33  |  Link
color
Registered User
 
color's Avatar
 
Join Date: May 2016
Posts: 235
I just want to say, this is amazing! I have used this script for 3 years now, and i just love it. I'm so happy when restoring old movies to be able to use tint as the original had. Big thank you.
__________________
Automatic Colorization
color is offline   Reply With Quote
Old 12th June 2021, 01:18   #34  |  Link
magiblot
Eurobeat Fan
 
Join Date: Sep 2014
Posts: 108
You are welcome, color! I'm glad to know it was helpful. Actually, I created this script for exactly that purpose. I wanted to color a black and white film and was unhappy with the existing filters.
magiblot is offline   Reply With Quote
Old 2nd July 2021, 05:30   #35  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,156
Quote:
Originally Posted by StainlessS View Post

Kino.avsi
Code:
Function Tint (clip Last, int color, int "strength") {
    strength = Default (strength, 128)
    hue = BlankClip (last, color = color, pixel_type = "YV12")
    # get chroma on new tint
    uhue = hue.UtoY ()
    vhue = hue.VtoY ()
    u = UtoY ()
    v = VtoY ()
    #set up mask. Assumes 0-255 RGB and 16-235 YUV.
    mask = GreyScale ()
    mask = mask.isYUV () ? mask.ColorYUV (levels = "tv->pc") : mask
    # mask 1 reduces chroma impact in shadows
    # mask 2 reduces chroma in highlights
    mask1 = mask.Levels (0, 1, 127, 0, 255, false)
    mask2 = mask.Levels (128, 1, 255, 255, 0, false)
    maskmask = mask.Levels (127, 1, 128, 0, 255, false)
    mask = Overlay (mask1, mask2, mask = maskmask).Levels (0, 1, 255, 0, strength, false)
    mask =  isYUY2 () ? mask.BilinearResize (Width/2, Height) : \
        isYV12 () ? mask.BilinearResize (Width/2, Height/2) : mask
    # mask combines the two masks and resizes to match chroma
    # apply tints to the chroma channels
    u1 = Overlay (u, uhue, mode = "luma", mask = mask)
    v1 = Overlay (v, vhue, mode = "luma", mask = mask)
    # mix new chroma into
    YtoUV (u1, v1, last)
}

Function KinoTint(clip c,int "Start", int "End",string "Name", Int "Color", Int "Strength",Bool "Show",Bool "ShowFrmNum") {
    # By Default applies to entire clip (useful to ClipClop for creation of entire tinted clips)
    Start=Default(Start,0)      End=Default(End,c.FrameCount-1)
    Name=Default(Name,"")       Color=Default(Color,$808080)                        Strength=Default(Strength,128)  # Mod if you want fixed default
    Show=Default(Show,False)    ShowFrmNum=Show?Default(ShowFrmNum,False):False
    ApplyRange (c, Start,End,"Tint",Color,Strength)
    Tit = (SHOW)       ? RT_String("Name=%s : Color=$%06X : Strength=%d",Name,Color,Strength) : ""
    Args= (ShowFrmNum) ? RT_String(",First_Frame=%d,Last_Frame=%d",Start,End) : ""
    Return (!Show)
        \ ? Last
        \ : (!ShowFrmNum)
        \   ? SubTitle(Tit,First_Frame=Start,Last_Frame=End)
        \   : Scriptclip("""Subtitle(String(current_frame,"%.0f] ") + """ + Chr(34) + Tit + Chr(34) + Args + ")")
}


Function ChrIsNul(String S)      {return RT_Ord(S)== 0}                             # End of String
Function ChrIsHash(String S)     {return RT_Ord(S)==35}                             # #
Function ChrIsDollar(String S)   {return RT_Ord(S)==36}                             # $
Function ChrIsEqual(String S)    {return RT_Ord(S)==61}                             # =
Function ChrIsHex(String S)      {C=RT_Ord(S) return C>=48&&C<=57||C>=65&&C<=70||C>=97&&C<=102}
Function ChrEatWhite(String S)   {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function ChrEatHex(String S)     {i=1 C=RT_Ord(S,i) While(C>=48&&C<=57||C>=65&&C<=70||C>=97&&C<=102) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}

Function GetVarNameFromString(string s) {
    i=0    c=RT_Ord(s,i+1)
    While(c==95 || (c>=65&&c<=90||c>=97&&c<=122) || (i>0&&(c>=48&&c<=57)))  { i=i+1 c=RT_Ord(S,i+1) }
    return i>0?LeftStr(s,i):""
}

Function Kino_CreateDBase(String ColorList_Filename,String DB) {
    # Create DBase, Field 0=Name, Field 1=color
    myName="Kino_CreateDBase: "
    Assert(ColorList_Filename!="",RT_String("%sError, Colorlist_FileName cannot be ''",myName))
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    ColorList_Filename=RT_GetFullPathName(ColorList_Filename)
    DB=RT_GetFullPathName(DB)
    Assert(Exist(ColorList_Filename),RT_String("%sError, %s does not exist",myName,ColorList_Filename))
    RT_DBaseAlloc(DB,0,"s64i")          # Field 0=String(Max 64 chars), Field 1=int
    # Create DBase with names and Color
    Color_List=RT_ReadTxtFromFile(ColorList_Filename)
    LINES=RT_TxtQueryLines(Color_List)
    for(i=0,LINES-1) {
        SS=RT_TxtGetLine(Color_List,i).ChrEatWhite
        S=SS
        if(!ChrIsNul(S) && !ChrIsHash(S)) {
            Name=GetVarNameFromString(S).UCase
            NameLen=StrLen(Name)
            S=MidStr(S,NameLen+1).ChrEatWhite
            if(Name=="GLOBAL") {
                Name=GetVarNameFromString(S).UCase
                NameLen=StrLen(Name)
                S=MidStr(S,NameLen+1).ChrEatWhite
            }
            Assert(ChrIsEqual(S),RT_String("%sError@Line_%d,  Expecting '='\n'%s'",myName,i+1,SS))
            S=MidStr(S,2).ChrEatWhite    # Skip '='
            Assert(ChrIsDollar(S),RT_String("%sError@Line_%d,  Expecting '$'\n'%s'",myName,i+1,SS))
            S=MidStr(S,2).ChrEatWhite    # Skip '$'
            Assert(ChrIsHex(S),RT_String("%sError@Line_%d,  Expecting hex number\n'%s'",myName,i+1,SS))
            HexCol=RT_HexValue(S)
            S=ChrEatHex(S).ChrEatWhite   # Skip Hex digits
            if(ChrIsHash(S)) {S=""}
            Assert(ChrIsNul(S),RT_String("%sError@Line_%d,  *** NON-PARSE ***\n'%s'",myName,i+1,SS))
            RT_DebugF("%d] Name=%s : HexCol=$%X",i+1,RT_StrPad(Name,32),HexCol,name=myName)
            RT_DBaseAppend(DB, Name, HexCol)
        }
    }
}

Function Kino_MakeClipString(clip c, String DB, Int "Strength") {
    # Eval on return string will create all clips
    myName="Kino_MakeClipString: "
    Strength=Default(Strength,128)
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    End=c.Framecount-1
    Clips=""
    Records=RT_DBaseRecords(DB) # Number of clips
    For(i=0,Records-1) {
        Name  = RT_DBaseGetField(DB,i,0)
        Color = RT_DBaseGetField(DB,i,1)
        Clips = RT_String("""%s%s=ORG.KinoTint(0,%d,"%s",$%06X,%d,SHOW,SHOWFRMNUM)\n""",Clips,Name,End,Name,Color,Strength)
    }
    RT_DebugF("\nClips=\n%s",Clips,name=myName)
    Return Clips
}

Function Kino_MakeNickNameString(String DB) {
    myName="Kino_MakeNickNameString: "
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    NickName = ""
    Records=RT_DBaseRecords(DB) # Number of clips
    For(i=0,Records-1) {
        Name     = RT_DBaseGetField(DB,i,0)
        NickName = RT_String("%s%s=%d\n",NickName,Name,i+1)
    }
    RT_DebugF("\nNickName=\n%s",NickName,name=myName)
    Return NickName
}

Function Kino_MakeFilterString(String DB) {
    myName="Kino_MakeFilterString: "
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    FilterString = "ClipClop(ORG"
    Records=RT_DBaseRecords(DB) # Number of clips
    For(i=0,Records-1) {
        Name = RT_DBaseGetField(DB,i,0)
        FilterString = RT_String("%s,\n    \ %s",FilterString,Name)
    }
    FilterString = RT_String("%s,\n    \ SCmd=SCMD,Cmd=CMD,NickName=NickName\n\\ )\n",FilterString)
    RT_DebugF("\nFilterString=\n%s",FilterString,name=myName)
    Return FilterString
}

Function Kino_MakeDemoString(clip c,String DB,Int "Len",Int "Gap") {
    myName="Kino_MakeDemoString: "
    Len=Default(Len,100)        Gap=Default(Gap,Len)   # GAP defaults to Len
    Assert(DB!="",RT_String("%sError, DB name cannot be ''",myName))
    DB=RT_GetFullPathName(DB)
    FC=c.FrameCount
    DemoString = ""
    Records=RT_DBaseRecords(DB) # Number of clips
    Start=Gap
    For(i=0,Records-1) {
        Name = RT_DBaseGetField(DB,i,0).RT_StrPad(32)
        End = Start + Len-1
        End = (End == 0) ? -1 : (End >= FC) ? FC-1 : End
        DemoString = RT_String("%s%s %d,%d\n",DemoString,Name,Start,End)
        Start=Start+Len+Gap
    }
    RT_DebugF("\nDemoString=\n%s",DemoString,name=myName)
    Return DemoString
}
Your kino.avsi still continued function duplicates with Duplicity2, DBSC and Zs_RF_Shared_v1.154

Code:
"ChrEatHex" : "C:\Program Files (x86)\AviSynth+\plugins+\DBSC.avsi"
"ChrEatHex" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
"ChrEatWhite" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
"ChrEatWhite" : "C:\Program Files (x86)\AviSynth+\plugins+\Zs_RF_Shared_v1.154.avsi"
"ChrIsDollar" : "C:\Program Files (x86)\AviSynth+\plugins+\DBSC.avsi"
"ChrIsDollar" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
"ChrIsEqual" : "C:\Program Files (x86)\AviSynth+\plugins+\DBSC.avsi"
"ChrIsEqual" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
"ChrIsHash" : "C:\Program Files (x86)\AviSynth+\plugins+\DBSC.avsi"
"ChrIsHash" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
"ChrIsHex" : "C:\Program Files (x86)\AviSynth+\plugins+\DBSC.avsi"
"ChrIsHex" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
"ChrIsNul" : "C:\Program Files (x86)\AviSynth+\plugins+\DBSC.avsi"
"ChrIsNul" : "C:\Program Files (x86)\AviSynth+\plugins+\Kino.avsi"
kedautinh12 is offline   Reply With Quote
Old 2nd July 2021, 13:48   #36  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thankyou,
Its no big deal to have duplicate functions, just uses a teensy bit extra memory,
avoids having to read in a separate full version of avsi script. [The full ChrIs???? is a lot bigger].

Just delete those half dozen function from the script if it bothers you.

EDIT: I did not realize that RF had added some to Zs_RF_Shared_v1.154.avsi.
EDIT: I did not think that anybody but Color would be using that script.
__________________
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 July 2021 at 13:52.
StainlessS is offline   Reply With Quote
Reply

Tags
film tinting

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 19:24.


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