Hi,
That's not too hard. First, you can get a full pixel average in masktools,
Code:
a=blankclip(pixel_type="YV12",color_yuv=$808080)
b=blankclip(pixel_type="YV12",color_yuv=$408080)
stackhorizontal(a,b)
mt_lutf(last,last,mode="avg",yexpr="x")
The test video has squares of 64 and 128 brightness, the average should be 96. The lutf command returns the pixel average, which is 96 everywhere. But now you need to work only on each line, so use my split lines function with it:
Code:
#Line Average v0.1 by jmac698
#Averages each horizontal line. Doesn't change video resolution.
#Requires GRunT, MaskTools v2
#set your source here
splitlines(1)
mt_lutf(last,last,mode="avg",yexpr="x")
MergeLines(480)
function SplitLines(clip c, int n) {#duplicates then crops each copy in a different spot
Assert(c.height%n == 0, "Clip height not a multiple of 'n'")
Assert(!(c.IsYV12() && n%2==1), "'n' must be even for YV12 clips")
nStrips = c.height/n
c = c.ChangeFPS(nStrips*Framerate(c)).AssumeFPS(c) # Repeat each frame 'nStrips' times
BlankClip(c, height=n) # template for ScriptClip result
GScriptClip("c.Crop(0, (current_frame%nStrips)*n, 0, n)", args="c, nStrips, n")
}
function MergeLines(clip c, int n) {MergeLines2(c,n,n)}
function MergeLines2(clip c, int n,int i) {
i<2?c.SelectEvery(n):stackvertical(MergeLines2(c,n,i-1),c.SelectEvery(n, i))
}