VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. Code:
    src=LSMASHVideoSource("filename.mp4", format="YUV420P10", fpsnum=25, fpsden=1).ConvertBits(8, dither=0).KillAudio()
    
    Function FrameAreaS(clip c, int L, int T, int R, int B, String Op) { # https://forum.doom9.org/showthread.php?p=1603343#post1603343
    
        # Modulo 4 coords
        L = L - (L % 4)
        T = T - (T % 4)
        R = (R + 3) / 4 * 4
        B = (B + 3) / 4 * 4
    
        Area=c.crop(L,T,R-L,B-T)
        Left = L > 0           ? c.crop(0,T,L,B-T)                 : NOP
        Top = T > 0          ? c.crop(0,0,c.width(),T)              : NOP
        Right = R < c.width()  ? c.crop(R,T,c.width()-R,B-T)      : NOP
        Bottom = B < c.height() ? c.crop(0,B,c.width(),c.height()-B)  : NOP
    
        Eval("Area." + OP)
        IsClip(Left)  ? StackHorizontal(Left, Last)  : NOP
        IsClip(Right) ? StackHorizontal(Last, Right) : NOP
        IsClip(Top) ? StackVertical(Top, Last)   : NOP
        IsClip(Bottom) ? StackVertical(Last, Bottom)   : NOP
        Return Last
    }
    
    #    current_frame=n
    #    fc=FrameCount()
    #    fa=FrameArea(src,0,100,0,1080)
    
    #SL="""
    For (n=0,src.FrameCount-1){
        current_frame=n
    #    fc=FrameCount()
    #    AL=AverageLuma
        if (current_frame < FrameCount){
            if (Eval(FrameAreaS(src,0,100,0,1080,"AverageLuma"))){
            }    if (AverageLuma < 16){
            SmoothLevels(0, 1.0, 255, 16, 235).Letterbox(0,0,240,240)
            } else {
            SmoothLevels(0, 1.0, 255, 16, 235)
            }
        }
        Return Last
    }
    #"""
    #GScriptClip(SL)
    
    StackHorizontal(src,last)
    #Return last
    I have many videos with 16/9 and some 4/3 with letterbox mixed in and the levels are off. I am trying to automate the tasks by detecting the letterbox. Using FrameAreaS to 'crop' the left side of the border and get the averageluma inside the 'crop' area. Should averageluma < 16 then apply filter else different filter.

    I have been messing around trying various iterations and either get "I don't know what framecount or averageluma or n means." or "invalid arguments to function framecount" or "average plane: this filter can only be used within run-time filter"

    Does anyone know how to get it to work?
    Quote Quote  
  2. I thought you got pretty good advice over in the doom9.org forum over the past week to your identical request:

    Letterbox detector

    Were you not able to get any of the proposed solutions to work?
    Quote Quote  
  3. Nope. I am not a programmer so I can't understand where I am going wrong. StainlessS is busy.

    Just came across this http://avisynth.nl/index.php/The_script_execution_model/Scope_and_lifetime_of_variables and thinking of creating another function similar to bracket_luma.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!