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 31st January 2023, 17:59   #21  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
Yes, subtitles take time to render, and every little helps. [SHOW=False]
MIN_SCENE_LEN = 1
its minimum frames to detect as scene?

btw ranges txt is for what?

Last edited by Hat3L0v3; 1st February 2023 at 02:00.
Hat3L0v3 is offline   Reply With Quote
Old 31st January 2023, 18:03   #22  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
An edit from previous post:
EDIT: I see Wonkey_Monkey there, I bet he's good at deshaking it all about.

Quote:
MIN_SCENE_LEN
You said you wanted minimum length scene, that is to set minimum length, but I reccommend you dont use it and leave at 1.

Ranges.txt is for whatever I/you might want it for, dont know, but its there anyways.

I see JohnMeyer there too, you seem to be in luck. [Call him Sir, he likes that].

EDIT:
You need script to deshake a single section, I'll make scripts to process entire clip using that as example.

EDIT: You'll need to post a sample for the guys.
__________________
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; 1st February 2023 at 10:06.
StainlessS is offline   Reply With Quote
Old 1st February 2023, 02:24   #23  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
An edit from previous post:
EDIT: I see Wonkey_Monkey there, I bet he's good at deshaking it all about.


You said you wanted minimum length scene, that is to set minimum length, but I reccommend you dont use it and leave at 1.

Ranges.txt is for whatever I/you might want it for, dont know, but its there anyways.

I see JohnMeyer there too, you seem to be in luck. [Call him Sir, he likes that].

EDIT:
You need script to deshake a single section, I'll make scripts to process entire clip using that as example.

EDIT: You'll need to post a somaple for the guys.
Sorry for not replying immediately, my power goes off. after that I went sleep

When I was trying to stabilize big parts of video manually - script was looking like this:

Code:
T1=Trim(0, 6738)

b2=Trim(6739, 6999)
d2 = DePanEstimate(b2, range=1, trust=1, dxmax=5, dymax=5)
T2 = DePanStabilize(b2, data=d2, mirror=15)

T3=Trim(7000, 10487)

So basically (for example) with my SFrames.txt that starts with
Code:
0
108
202
4_part must looks something like this:
Code:
#input part
everything that need to be loaded (like DGSource(VideoFileName), txt, other)

#param inputs part

param1=5 #frames before SOS
param2=0 #frames that count SOS and add some more ahead
settings1=  #settings for DePanEstimate (In my case it will be range=1, trust=1, dxmax=5, dymax=5)
settings2=  #settings for DePanStabilize (In my case only mirror=15 but there are more)

#part that split intervals into 2parts

(script)

In my case with param1+2 = 5+0 it must create intervals like:
part1A=(0,102)
part1B=(103,107)
part2A=(108,196)
...etc...
With param1+2 = 5+2 it must create intervals like:
part1A=(0,102)
part1B=(103,109)
part2A=(110,196)
...etc...

#part for creating data for depanstab and stabilize

(script that do something like this):

1B=last.Trim(part1B)
data1= DePanEstimate(1B, settings1)
stab1= DePanStabilize(1B, data=data1, settings2)

2B=last.Trim(part2B)
data2= DePanEstimate(2B, settings1)
stab2= DePanStabilize(2B, data=data2, settings2)

...etc...

#part that trims and merge everything together

(something like this):

part1=last.Trim(part1A)
part2=stab1
part3=last.Trim(part2A)
part4=stab2
...etc...

Output=part1+part2+part3+...etc...
Output
Ofcource it's from my noob perspective. Some parts must be written in other (proper) way.
I don't know how to do part with data if I want to use other filter that not require data (like Stab3 for example, it must run only stab1= Stab3(1B, settings3) )

For 3_Show_Cuts script , I would like to see info about how much frames are to closest SOS/EOF (I guess closest previous SOS for left prewiev, and closest next EOF for right prewiev) so I can see where are short parts of scenes.

Last edited by Hat3L0v3; 1st February 2023 at 02:27.
Hat3L0v3 is offline   Reply With Quote
Old 1st February 2023, 12:57   #24  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
I would like to see info about how much frames are to closest SOS/EOF (I guess closest previous SOS for left prewiev, and closest next EOF for right prewiev) so I can see where are short parts of scenes.
OK, I added two fields to DBase, Field_3=PrevSceneLen, Field_4=NextSceneLen.

Global.avs
Code:
# Global.avs

VideoFileName = "D:\LF.dgi"
SFrames       = ".\SFrames.txt".RT_GetFullPathName()
Ranges        = ".\Ranges.txt".RT_GetFullPathName()         # Ranges file written during making DBase.
DB            = ".\MyDB.DB".RT_GetFullPathName()
#LoadPlugin(".\RT_stats_x64.dll")

######################
# Example TypeString:- "ifffs1024bn", 1st field Int, 3 Float fields, 1 string field of length=1024, 1 Bool field, 1 BIN field(8 bit int). 7 Fields in all (0->6).
DB_TypeString = "iiiii"                         # Field_0=StartFrameNo, Field_1=EndFrameNo, Field_2=SceneLength, Field_3=PrevSceneLength, Field_4=NextSceneLength,

DGSource(VideoFileName)

# My Trim to shorten sample file
Trim(10000,-10000) # 10,000 frame

CROP_X=0 CROP_Y=132 CROP_W=-0 CROP_H=-132       # My Crop Coords, get rid of border

crop(CROP_X,CROP_Y,CROP_W,CROP_H)

SOURCE_CLIP = Last    # NOT Converted to 8 bit

bpc = Last.BitsPerComponent
(bpc != 8) ? ConvertBits(8) : NOP

Spline36Resize(480,360)                         # Maybe improve detect with MvTools, maybe another reiszer or size. Can just comment out.

Return Last
1_Make_SFrames.avs [No Change]
Code:
# 1_Make_SFrames.avs

Import(".\ScSelect_HBD.avsi")
Import(".\Global.avs")          # Set SFrames name and load clip, trim, crop, convertbits and anything else needed in all processing files.

##########################

DFACTOR   = 8.0                 # Way high
MINDIF    = 12.0                # Way high
SHOW      = True                # Turn off during full fast scan (SHOW=False)

# Function SCSelect_HBD(clip dClip,clip Start,clip End,clip Motion, float "dfactor",Float "MinDif",bool "show",String "S_Frames",String "E_Frames")

SZ = Max(Round(Height*0.10),24)
Start=Subtitle("START OF SCENE",align=5,size=SZ,Y=Height/2-SZ,Text_Color=$FF4040)
End=Subtitle("END OF SCENE",    align=5,size=SZ,Y=Height/2+SZ,Text_Color=$4040FF)
Motion=Subtitle("GLOBAL MOTION",align=5,size=SZ)

RT_FileDelete(SFrames)
RT_FileDelete(Ranges)

SCSelect_HBD(Last,Start,End,Motion,dFactor=DFACTOR,MinDif=MINDIF,show=SHOW,S_Frames=SFrames)        # When Happy, Use VDub "Run Video Analysis pass".


return last
1B_Make_SFramesB.avs [No Change]
Code:
# 1B_Make_SFramesB.avs

Import(".\ScSelect_HBD.avsi")
Import(".\Global.avs")          # Set SFrames name and load clip, trim, crop, convertbits and anything else needed in all processing files.

##########################
RT_FileDelete(SFrames)
RT_FileDelete(Ranges)

thSCD1 = 400
thSCD2 = 130
SHOW   = True

SOS = StartOfSceneClip(thSCD1,thSCD2)
SZ = Max(Last.Height*.1,24)

GLOBAL SOSCNT = 0

SSS="""
    Y = SOS.RT_Averageluma(w=1,h=1)
    if(Y >= 255) {
        RT_WriteFile(SFrames,"%d",current_Frame,Append=True)
        GLOBAL SOSCNT = SOSCNT + 1
    }
    (SHOW) ? Subtitle(RT_String("SOS=%s : SOSCNT=%d",(Y>=255),SOSCNT),size=SZ,text_color=(Y>=255)?$FF0000:$FFFF00,align=5) : NOP
    Return Last
"""
ScriptClip(SSS)
return last

Function StartOfSceneClip(clip c,Int "thSCD1",Int "thSCD2") { # All Luma Samples set 255 at SOS, else 0
    thSCD1=Default(thSCD1,400)  thSCD2=Default(thSCD2,130)
    sup=c.MSuper(pel=1,sharp=0,rfilter=2,hpad=16, vpad=16)
    fv=sup.MAnalyse(isb=false,delta=1,blksize=16)
    Return c.MSCDetection(fv,thSCD1=thSCD1,thSCD2=thSCD2)
}
2_Make_DBase.avs [Changes]
Code:
# 2_Make_DBase.avs

Import(".\Global.avs")          # Set SFrames name and load clip, trim, crop, convertbits and anything else needed in all processing files.

MIN_SCENE_LEN = 1               # Whatever you choose (1 will switch off limiting)

##########################
RT_FileDelete(Ranges)

S = RT_ReadTxtFromFile(SFrames)
LINES = RT_TxtQueryLines(S)
RT_DBaseAlloc(DB,0,DB_TypeString)               # Create DBase file, with zero pre-existing records, number and type of fields as described by DB_TypeString.
                                                # Here, We dont know how many records there will be.
Start   = 0
Record  = 0
For(i=0,LINES-1) {
    n = S.RT_TxtGetLine(LINE=i).RT_NumberValue()
    if(n > 0) { # Skip both zeros in SFrames
        End = n - 1                             # End frame is frame before a Start frame.
        Length = End - Start + 1
        if(Length >= MIN_SCENE_LEN) {
            RT_WriteFile(Ranges,"%d %d",Start,End,Append=true)
            # Record is the SceneNo (Zero Relative)
            RT_DBaseExtend(DB)                      # Add an empty record, Record = Zero Rel record index # All fields are zeroed (Strings = "", Bool=false).
            RT_DBaseSetField(DB,Record,0,  Start)   # Field 0 = Start of Scene
            RT_DBaseSetField(DB,Record,1,  End)     # Field 1 = End of Scene
            RT_DBaseSetField(DB,Record,2,  Length)  # Field 2 = Length of Scene
            # Set Prev Scene Length and Next Scene Length Fields
            PrevLen = (Record==0) ? 0 : RT_DBaseGetField(DB,Record-1,2)         # Get Length of Previous Scene
            RT_DBaseSetField(DB,Record,3, PrevLen)                              # Set current Record Field 3 with length of Previous Scene.
            (Record==0) ? NOP : RT_DBaseSetField(DB,Record-1,4, Length)         # Set Prev Record Field 4 (next scene len) with length of current Scene.
            # Set any further Fields as desired and as described via DB_TypeString.

            Start = n                               # For Next time around
            Record = Record + 1                     # Number of records in DBase so far (and next time around zero relative record number).
        }
    }
}
# REPEAT SETTING OF ALL fields for last record
End = FrameCount - 1
RT_WriteFile(Ranges,"%d %d",Start,End,Append=true)

Length = End - Start + 1
RT_DBaseExtend(DB)                      # Add final empty record
RT_DBaseSetField(DB,Record,0,  Start)   # Field 0 = Start of Scene
RT_DBaseSetField(DB,Record,1,  End)     # Field 1 = End of Scene
RT_DBaseSetField(DB,Record,2,  Length)  # Field 2 = Length of Scene
# Set Prev Scene Length and Next Scene Length Fields
PrevLen = RT_DBaseGetField(DB,Record-1,2)       # Get Length of Previous Scene
RT_DBaseSetField(DB,Record,3, PrevLen)          # Set current Record Field 3 with length of Previous Scene.
RT_DBaseSetField(DB,Record-1,4, Length)         # Set Prev Record Field 4 (next scene len) with length of current Scene.

# Set any further Fields as desired and as described via DB_TypeString.


Record = Record + 1                     # Number of records in DBase
return MessageClip(RT_String("Wrote %d Records (trims)",Record))
3_Show_Cuts.avs [Changes, quite a few, not marked]
Code:
# 3_Show_Cuts.avs

Import(".\Global.avs")          # Set SFrames name and load clip, trim, crop, convertbits and anything else needed in all processing files.

Records = RT_DBaseRecords(DB)

Src = SOURCE_CLIP

C = Src.BlankClip(length=0,Width=Src.Width*2)                 # zero len clip (double width)

INVALID_FRAME = Src.BlankClip(length=1,Color=$FF00FF)         # Frame before 0 or after last frame.

SZ = Max(Round(Height*0.10),24)

# Subtitled Scene numbers are 1 relative.

for(rec=0,Records) { # *** WARNING ***, rec=Records record dont exist, just for showing FINAL EOS of previous scene.
    LenOfCurrScene = (rec!=Records) ? RT_DbaseGetField(DB,rec, 2) : 0                             # Length of Current  scene from Field 2
    LenOfPrevScene = (rec!=Records) ? RT_DbaseGetField(DB,rec, 3) : RT_DbaseGetField(DB,rec-1, 2) # Length of Previous scene (Use current len of previous scene if rec=Records)
    LenOfNextScene = (rec!=Records) ? RT_DbaseGetField(DB,rec, 4) : 0                             # Length of Next scene from Field 4
    if(LenOfPrevScene==0) {
        EndC = INVALID_FRAME                                  # Frame before Scene 0 is INVALID
    } Else {
        EndOfPreviousScene = RT_DbaseGetField(DB,rec-1, 1)    # Last frameNo of previous scene (Field 1 is End frame)
        EndC = Src.Trim(EndOfPreviousScene,-1)                # End frame of SceneCut(rec-1)
        EndC = EndC.Subtitle(RT_String("%d] Prev EOS : Scene %d/%d Len=%d",EndOfPreviousScene,rec-1+1,Records,LenOfPrevScene),Size=SZ)
    }
    if(LenOfCurrScene==0) {
        StartC = INVALID_FRAME                                # Final Frame + 1, Invalid
    } Else {
        StartOfCurrScene = RT_DbaseGetField(DB,rec, 0)        # Field 0 is Start (current scene)
        StartC = Src.Trim(StartOfCurrScene,-1)                # Start frame of SceneCut(rec)
        StartC = StartC.Subtitle(RT_String("%d] Curr SOS : Scene %d/%d : Len=%d\\nPrevLen=%d : NextLen=%d",
            \ StartOfCurrScene,rec+1,Records,LenOfCurrScene,LenOfPrevScene,LenOfNextScene),Size=SZ,lsp=0)
    }
    CutC   = StackHorizontal(EndC,StartC)
    C = C + CutC                                              # Add to clip so far
}
return C
EDIT: Looks like this, showing Curr, Prev and Next lengths.


EDIT:
Quote:
# *** WARNING ***, rec=Records record dont exist, just for showing FINAL EOS of previous scene.
Above, in my sample, we have only 50 scenes, but show 51 frames, last frame shows only final frame in clip as EOS of final scene. [SOS of next scene dont exist]

EDIT I'm off t' pub.
__________________
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 February 2023 at 13:18.
StainlessS is offline   Reply With Quote
Old 1st February 2023, 17:04   #25  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
OK, I added two fields to DBase, Field_3=PrevSceneLen, Field_4=NextSceneLen.
Thanks for changes. 4_part it's not your specialization?
Hope someone can write it, using DB that you help to create.
Hat3L0v3 is offline   Reply With Quote
Old 1st February 2023, 17:24   #26  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
In pub.

You need start and end and eg preframes and postframes in your script.

Edit: variables
__________________
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 February 2023, 03:37   #27  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
In pub.

You need start and end and eg preframes and postframes in your script.

Edit: variables
I don't understand what it means. start and end of parts that I want to filter? something like:
Code:
start = SOS -1 -param1
end = SOS -1 +param2
and what eg preframes/postframes means? frames before start/after end?
Hat3L0v3 is offline   Reply With Quote
Old 2nd February 2023, 11:14   #28  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
frames before start/after end?
Yes, explicit frame numbers are not of use to me, eg
Code:
PreFrames  = 5
PostFrames = 5

# both of current trim.
oStart = SOS
oEnd   = EOS

# Outer start and end of current trim
oStart = oStart - Min(PreFrames,LengthOfPrevTrim)   # I'll do the worrying about actual implementation
oEnd   = oEnd   + Min(PostFrames,LengthOfNextTrim)  # I'll do the worrying about actual implementation
By the way, something I should have asked in my 1st post,

Are you sure that you need to process in separate trims, people usually just process the entire clip.
(I had presumed that you know what you are doing)

(Perhaps JohnMeyer or somebody more familiar with Deshaker stuff could comment on Hat3Ov3's reason when they give it)
__________________
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 February 2023 at 11:24.
StainlessS is offline   Reply With Quote
Old 2nd February 2023, 12:13   #29  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
By the way, something I should have asked in my 1st post,

Are you sure that you need to process in separate trims, people usually just process the entire clip.
(I had presumed that you know what you are doing)
Well, I can use deshaked on entire clip, but I can't use all parts and scenes because it make worse some of them (like background start shaking to responds character movement).I tried to find parameters that can work in both ways, but: -or deshaker not working enough to stab frames well but not ruining other parts; -or it's stab scenes/frames and ruining other scenes.
So the only way I see - its use deshaker only for places where it needed : 1 - shifting frames before every scene changes (thay are too many for single episode to do it manually); 2 - scenes where deshaker needed (this part I can do manually because not so many of them)
And the only way I know how to do it - it's trim original part and filtered parts.
If you know how to replace this parts without trimming - go ahead. I'm just too noob in all of this stuff.
Hat3L0v3 is offline   Reply With Quote
Old 2nd February 2023, 12:37   #30  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, I get it now.

If you can decide upon a number (say half a dozen or so) different groups of settings, and create separate clips for each, and then can use ClipClop function, to
apply those settings to appropriate ranges.

ClipClop:- https://forum.doom9.org/showthread.p...light=ClipCLop

Example usage script using NickNames (instead of clip index numbers):
Code:
###
#   ColorBars(Pixel_Type="YV12")
    Avisource("D:\avs\test.avi") 

    ORG=Last

    V1 = FFT3DFilter(Plane=0,Sigma=1.6)     # Light Luma
    V2 = FFT3DFilter(Plane=0,Sigma=2.0)     # Med   Luma
    V3 = FFT3DFilter(Plane=0,Sigma=4.0)     # High  Luma
    V4 = FFT3DFilter(Plane=3,Sigma=1.6)     # Light Chroma
    V5 = FFT3DFilter(Plane=3,Sigma=2.0)     # Med   Chroma
    V6 = FFT3DFilter(Plane=3,Sigma=4.0)     # High  Chroma
    V7 = FFT3DFilter(Plane=4,Sigma=1.6)     # Light Luma+Chroma
    V8 = FFT3DFilter(Plane=4,Sigma=2.0)     # Med   Luma+Chroma
    V9 = FFT3DFilter(Plane=4,Sigma=4.0)     # High  Luma+Chroma
    V10= FlipHorizontal()                   # Flip-H
    V11= FlipVertical()                     # Flip-V
    V12= Invert()                           # Invert

    NickNames ="""  # Psuedonyms for clips (clip index number)
        L0   = 1    # Light Luma
        L1   = 2    # Med   Luma
        L2   = 3    # High  Luma
        C0   = 4    # Light Chroma
        C1   = 5    # Med   Chroma
        C2   = 6    # High  Chroma
        LC0  = 7    # Light Luma + Chroma
        LC1  = 8    # Med   Luma + Chroma
        LC2  = 9    # High  Luma + Chroma
        FH   = 10   # Flip-H
        FV   = 11   # Flip-V
        INV  = 12   # Invert
    """

    SCMD="""          # Clip editing commands in string, can also use commands in file
        C0  0,99      # Light Chroma frames @ 0 -> 99
        L0  100,-200  # Light Luma frames @ 100, 200 frames ie frames 100->299
        INV 300,399   # Invert 300->399
        L0  400,499   # Light Luma frames 400->499
        FH  500,599   # Flip-H 500->599
        LC2 600,699   # High Luma + Chroma
        C1  800       # Med Chroma, Single frame
        1   900,999   # Light Luma, We used the clip number instead of a NickName
        FV  1000,1099 # Flip-V
        LC1 2000,0    # Med   Luma + Chroma, 2000 -> lastframe
    """

    SHOW=True

    ClipClop(ORG,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,scmd=SCMD,nickname=NickNames,show=SHOW)
Above, V1 -> V12 are processed clips [entire clip deshaked with different settings],
The ranges that are not replaced are same as source clip.
In SCMD or CMD file, clip Index 1, or nickname L0 correspond with V1 clip, etc.

If above can suffice, then all and good, I have not wasted my time on the other scripts, it was an interesting excursion,
and could come in handy for other purposes.

EDIT: You can try above example script on some clip or even colorbars.

Supports source clip, and up to 255 edited clips [V1 ... V12 above], those not replaced remain as Source.
__________________
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 February 2023 at 12:50.
StainlessS is offline   Reply With Quote
Old 2nd February 2023, 13:10   #31  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
You can use the Range.txt generated by the other scripts, but need to insert a command clip index number for the replacement clip, or a NickName.
With Show=true, will show nicknames/clip index used in ClipClop.
NOTE, Every range in CMD (range.txt) will NEED an INDEX, can use 0 to remain as the src, I'll mod the Make DBase script to output eg "0 1234 5678",
so that it will by default do nothing for each range, and just mod your script as and when necessary.

You have to supply all Vn style clips for however many index/Nicknames you use.

2_Make_DBase.avs [Modded Range.txt for ClipClop]
Code:
# 2_Make_DBase.avs

Import(".\Global.avs")          # Set SFrames name and load clip, trim, crop, convertbits and anything else needed in all processing files.

MIN_SCENE_LEN = 1               # Whatever you choose (1 will switch off limiting)

##########################
RT_FileDelete(Ranges)

S = RT_ReadTxtFromFile(SFrames)
LINES = RT_TxtQueryLines(S)
RT_DBaseAlloc(DB,0,DB_TypeString)               # Create DBase file, with zero pre-existing records, number and type of fields as described by DB_TypeString.
                                                # Here, We dont know how many records there will be.
Start   = 0
Record  = 0
For(i=0,LINES-1) {
    n = S.RT_TxtGetLine(LINE=i).RT_NumberValue()
    if(n > 0) { # Skip both zeros in SFrames
        End = n - 1                             # End frame is frame before a Start frame.
        Length = End - Start + 1
        if(Length >= MIN_SCENE_LEN) {
#            RT_WriteFile(Ranges,"%d %d",Start,End,Append=true)
            RT_WriteFile(Ranges,"0    %d %d",Start,End,Append=true)
            # Record is the SceneNo (Zero Relative)
            RT_DBaseExtend(DB)                      # Add an empty record, Record = Zero Rel record index # All fields are zeroed (Strings = "", Bool=false).
            RT_DBaseSetField(DB,Record,0,  Start)   # Field 0 = Start of Scene
            RT_DBaseSetField(DB,Record,1,  End)     # Field 1 = End of Scene
            RT_DBaseSetField(DB,Record,2,  Length)  # Field 2 = Length of Scene
            # Set Prev Scene Length and Next Scene Length Fields
            PrevLen = (Record==0) ? 0 : RT_DBaseGetField(DB,Record-1,2)         # Get Length of Previous Scene
            RT_DBaseSetField(DB,Record,3, PrevLen)                              # Set current Record Field 3 with length of Previous Scene.
            (Record==0) ? NOP : RT_DBaseSetField(DB,Record-1,4, Length)         # Set Prev Record Field 4 (next scene len) with length of current Scene.
            # Set any further Fields as desired and as described via DB_TypeString.

            Start = n                               # For Next time around
            Record = Record + 1                     # Number of records in DBase so far (and next time around zero relative record number).
        }
    }
}
# REPEAT SETTING OF ALL fields for last record
End = FrameCount - 1
# RT_WriteFile(Ranges,"%d %d",Start,End,Append=true)
RT_WriteFile(Ranges,"0    %d %d",Start,End,Append=true)
Length = End - Start + 1
RT_DBaseExtend(DB)                      # Add final empty record
RT_DBaseSetField(DB,Record,0,  Start)   # Field 0 = Start of Scene
RT_DBaseSetField(DB,Record,1,  End)     # Field 1 = End of Scene
RT_DBaseSetField(DB,Record,2,  Length)  # Field 2 = Length of Scene
# Set Prev Scene Length and Next Scene Length Fields
PrevLen = RT_DBaseGetField(DB,Record-1,2)       # Get Length of Previous Scene
RT_DBaseSetField(DB,Record,3, PrevLen)          # Set current Record Field 3 with length of Previous Scene.
RT_DBaseSetField(DB,Record-1,4, Length)         # Set Prev Record Field 4 (next scene len) with length of current Scene.

# Set any further Fields as desired and as described via DB_TypeString.


Record = Record + 1                     # Number of records in DBase
return MessageClip(RT_String("Wrote %d Records (trims)",Record))
OOooops, forgot to write the last range, fixed above.
__________________
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 February 2023 at 13:19.
StainlessS is offline   Reply With Quote
Old 2nd February 2023, 13:19   #32  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
Above, V1 -> V12 are processed clips [entire clip deshaked with different settings],
The ranges that are not replaced are same as source clip.
In SCMD or CMD file, clip Index 1, or nickname L0 correspond with V1 clip, etc.

If above can suffice, then all and good, I have not wasted my time on the other scripts, it was an interesting excursion,
and could come in handy for other purposes.

EDIT: You can try above example script on some clip or even colorbars.

Supports source clip, and up to 255 edited clips [V1 ... V12 above], those not replaced remain as Source.
Don't really understand how it works, yet.
I don't have proper intervals yet. I need script that can make them (convert SOS and EOF with depends to how many frames param1,2)

upd. I guess to convert that created ranges like this:
Code:
0 702       ->   698 702       ->     698 704
703 893     ->   889 893       ->     889 895   
894 976     ->   972 976       ->     972 978   
977 1190    ->   1186 1190     ->     1186 1192    

original    ->  if param1 = 5  ->   if param1 = 5    
 ranges            param2 = 0          param2 = 2

Last edited by Hat3L0v3; 2nd February 2023 at 13:40.
Hat3L0v3 is offline   Reply With Quote
Old 2nd February 2023, 13:59   #33  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
So what I understand - I need to put stabilizer into V1=depanstab(blablabla) . L0 = name1 (just a name?) . and somehow import ranges.txt into SCMD= (don't know how to do it)

But if depanstab need to run esimate for data (like depanestimate(source, parameters) - where to put it on? just somewhere above script? or I can just run like:
Code:
###
    Avisource("D:\avs\test.avi")
    ORG=Last

data1=depanestimate(last, params1)
stab=depanstabilize(last, data=data1, params2)


    V1 = stab     # stabilized

    NickNames ="""  # Psuedonyms for clips (clip index number)
        L0   = 1    # Light Luma

    SCMD="...path.../ranges.txt"          # this part I dont know how to import
        
    """

    SHOW=false #

    ClipClop(ORG,V1,scmd=SCMD,nickname=NickNames,show=SHOW)
Hat3L0v3 is offline   Reply With Quote
Old 2nd February 2023, 14:04   #34  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
OK, I guess I did not think about it too much, I forgot the extra few frames.

Can you get rid of most of the deshaken clip using just a few settings and no before and after extra frames, and write result clip to AVI, (process as per clipclop).
Then we concentrate on the fewer awkward ranges.
Is that possible, or are all of them awkward ?

EDIT:
Can create two pass filtering like this [Using either ForceProcessAVI() from TWriteAvi dll, or RT_ForceProcess() from RT_Stats.]

Code:
WhateverSource(...)
Clip1 = Trim(0,-2000) # 2000 frames
File1="D:\File1.txt"
Clip2 = Trim(2000,0) # remainder
File2="D:\File2.txt"
Clip1.A_Two_Pass_Function(Pass=1,LogFile=File1)
ForceProcessAVI()           # Clip1, Force Pass 1
Clip2.A_Two_Pass_Function(Pass=1,LogFile=File2)
ForceProcessAVI()           # Clip2, Force Pass 1
Result1 = Clip1.A_Two_Pass_Function(Pass=2,LogFile=File1) # Clip 1 Pass 2
Result2 = Clip2.A_Two_Pass_Function(Pass=2,LogFile=File2) # Clip 2 Pass 2
return Result1++Result2
OR another with only single clip
Code:
WhateverSource(...)
Clip1 = Trim(1000,1999) # 2000 frames
File1="D:\File1.txt"
Clip1.A_Two_Pass_Function(Pass=1,LogFile=File1)
ForceProcessAVI()           # Clip1, Force Pass 1
Result1 = Clip1.A_Two_Pass_Function(Pass=2,LogFile=File1) # Clip 1 Pass 2
Return Trim(0,999) + Clip1 + Trim(2000,0)
EDIT: Oh good, my bread is done, now for some bacon, egg and mushrooms ,with fresh baked bread.

EDIT: Or another example from this thread:- https://forum.doom9.org/showthread.p...er#post1782861

Quote:
DS_ForceProcess(clip, Bool "Debug"=True)
Useful where a clip outputs some kind of file for use in a second filter, this function would in such a case
forcibly read the clip, and therefore write the file, so that it may be available to other filters or to a second pass of the filter that
initially wrote the file.
Debug, default true. Write Progress to DebugView (Google).
Returns only after completed force reading of video frames (and audio samples if any).
Returns 0.
Example, Auto 2 Pass script:-
Code:
    LoadVirtualDubPlugin ("Deshaker.vdf", "deshaker", preroll=0)
    FN="F:\Shaky.avi"
    AviSource(FN).ConvertToRGB32.Trim(10000,-500)
    DUMMY=Some2PassFunc(Pass=1)   # A script function that calls Deshaker to produce log file.
    DS_ForceProcess(DUMMY)        # Forcibly read all frames in clip and output deshaker.log.
    DUMMY=0                       # KILL DUMMY clip (Call Deshaker Destructor and close deshaker.log, so that can be reopened for pass 2)
    Some2PassFunc(Pass=2)         # Pass 2 deshaker function.
    Return Last
__________________
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 February 2023 at 14:58.
StainlessS is offline   Reply With Quote
Old 2nd February 2023, 15:02   #35  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
OK, I guess I did not think about it too much, I forgot the extra few frames.

Can you get rid of most of the deshaken clip using just a few settings and no before and after extra frames, and write result clip to AVI, (process as per clipclop).
Then we concentrate on the fewer awkward ranges.
Is that possible, or are all of them awkward ?

EDIT:
Can create two pass filtering like this [Using either ForceProcessAVI() from TWriteAvi dll, or RT_ForceProcess() from RT_Stats.]

Code:
WhateverSource(...)
Clip1 = Trim(0,-2000) # 2000 frames
File1="D:\File1.txt"
Clip2 = Trim(2000,0) # remainder
File2="D:\File2.txt"
Clip1.A_Two_Pass_Function(Pass=1,LogFile=File1)
ForceProcessAVI()           # Clip1, Force Pass 1
Clip2.A_Two_Pass_Function(Pass=1,LogFile=File2)
ForceProcessAVI()           # Clip2, Force Pass 1
Result1 = Clip1.A_Two_Pass_Function(Pass=2,LogFile=File1) # Clip 1 Pass 2
Result2 = Clip2.A_Two_Pass_Function(Pass=2,LogFile=File2) # Clip 2 Pass 2
return Result1++Result2
OR another with only single clip
Code:
WhateverSource(...)
Clip1 = Trim(1000,1999) # 2000 frames
File1="D:\File1.txt"
Clip1.A_Two_Pass_Function(Pass=1,LogFile=File1)
ForceProcessAVI()           # Clip1, Force Pass 1
Result1 = Clip1.A_Two_Pass_Function(Pass=2,LogFile=File1) # Clip 1 Pass 2
Return Trim(0,999) + Clip1 + Trim(2000,0)
EDIT: Oh good, my bread is done, now for some bacon, egg and mushrooms ,with fresh baked bread.
man, I can't understand what are you talking about... what this A_Two_Pass_Function do? your ClipClop filter doesn't do what I wanted to do?
Am I explaining bad? I have ranges that you help to create, I need to apply deshaker to last 5frames of every scene. thats why I need to convert them like this:
Code:
0 702       ->   698 702       ->     698 704
703 893     ->   889 893       ->     889 895   
894 976     ->   972 976       ->     972 978   
977 1190    ->   1186 1190     ->     1186 1192    

original    ->  if param1 = 5  ->   if param1 = 5    
 ranges            param2 = 0          param2 = 2
other parts are beeing untouched (like you said your clipclop do)
Hat3L0v3 is offline   Reply With Quote
Old 2nd February 2023, 15:27   #36  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Basically, that is how you can process a two pass script,

eg, pass1 make a deshaker log,

pass2, deshake the clip.

Instead of two different scripts.

give me time, I'll try figure something out.
__________________
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 February 2023, 15:43   #37  |  Link
Hat3L0v3
Registered User
 
Hat3L0v3's Avatar
 
Join Date: Dec 2022
Posts: 44
Quote:
Originally Posted by StainlessS View Post
Basically, that is how you can process a two pass script,

eg, pass1 make a deshaker log,

pass2, deshake the clip.

Instead of two different scripts.

give me time, I'll try figure something out.
I'm not hurry you, I'm just not programmer to understand your program language.
Imagine you trying to explain Quantum field theory to a monkey that are looking at you like on God. I need something more simple like: banana -> mouth -> eat ->
If I tried to load your ClipClop as avs/avsi it gives me error: Platform returned code 193: %1 Is Not a Valid Win32 Application
Hat3L0v3 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 18:04.


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