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.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 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?
+ Reply to Thread
Results 1 to 3 of 3
-
-
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? -
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.
Similar Threads
-
Mp4Box - Output is generated without frame Width, frame height & frame rate
By Saptarshi in forum Newbie / General discussionsReplies: 0Last Post: 25th Nov 2022, 08:27 -
Flowblade and pixelize specific frame area
By danjde in forum LinuxReplies: 0Last Post: 23rd Jan 2021, 05:55 -
Problem with Premiere frame size and motion scale on frame hold
By miguelmorin in forum EditingReplies: 0Last Post: 10th Jan 2021, 17:20 -
Bluring an area with AviUtl
By ChasVideo in forum EditingReplies: 1Last Post: 25th Dec 2018, 20:41 -
Frame Rate, Bitrates ans Frame by frame comparison
By novreis in forum Newbie / General discussionsReplies: 1Last Post: 5th Feb 2018, 17:40