Log in

View Full Version : z = AverageLuma()


lisztfr9
25th October 2012, 14:01
Hi,

I can't really see why the z = AverageLuma() line isn't working, since "last" argument is implicit, and such a syntax can also be fund here :


http://avisynth.org/mediawiki/Internal_functions/Runtime_functions

Examples:

threshold = 55
luma = AverageLuma()

Here is my code, it works with version(). The other source is simply the test video from VD, Pulldown TTF, deinterlaced.


video=AviSource("C:\Documents and Settings\main\Desktop\OBALDIA.vdr").ConvertToYV12()
/*
Version() ConvertToYV12() # Generate a test clip
video = last
*/

# Split the clip in 2 parts, displaying luma on each.

w = width(video)
h = height(video)

# z = AverageLuma()

A = video.crop(0, 0, -w/2, 0)
A = A.ScriptClip(" Subtitle(String(AverageLuma())) ")


B = video.crop(w/2, 0, 0, 0)
B = B.ScriptClip(" Subtitle(String(AverageLuma())) ")

A=A.AddBorders(0, 0, 4, 0, $FFFF00)

StackHorizontal(A, B)

FadeIn(20)
trim(1, 500)



TIA, L

wonkey_monkey
25th October 2012, 14:28
"last" is only implicit if you're not assigning your clip to a variable - which you are:


video=AviSource("C:\Documents and Settings\main\Desktop\OBALDIA.vdr").ConvertToYV12() # no implicit "last"

AviSource("C:\Documents and Settings\main\Desktop\OBALDIA.vdr").ConvertToYV12() # implicit "last"


David

lisztfr9
25th October 2012, 16:22
http://forum.videohelp.com/threads/317881-improve-old-VHS/page3

I should use Scriptclip, but scriptclip must return a video, so i will try Conditional Filtering.

lisztfr9
25th October 2012, 18:39
I just wanted to print "hello world" on the side of the video witch had the most AverageLuma.

I have only learned Qbasic... this is very different, also imho there are some inconsistencies, for example inside ConditionalFiltering the syntax is not the same as in the Scriptclip channel, mainly the quotes are different.

The problem is, that after the conditional filtering, i cannot put the video together.

Thanks, L



video=AviSource("C:\Documents and Settings\main\Desktop\OBALDIA.vdr").ConvertToYV12()

/*
Version() ConvertToYV12() # Generate a test clip
video = last
*/

w = width(video)
h = height(video)

A = video.crop(0, 0, -w/2, 0)
B = video.crop(w/2, 0, 0, 0)

A = A.ScriptClip(" Subtitle(String(AverageLuma())) ")
B = B.ScriptClip(" Subtitle(String(AverageLuma())) ")

ConditionalFilter(video, A, B, "AverageLuma(A)", ">", "AverageLuma(B)")
Subtitle("hello world!", align = 5)

Function sort (A, B, C) {
AverageLuma(A) > AverageLuma(B) ? C = A : C = B
Return C }

sort (A, B, C)

# StackHorizontal()

FadeIn(20)
trim(1, 500)

Gavino
25th October 2012, 19:38
I just wanted to print "hello world" on the side of the video witch had the most AverageLuma.
Instead of
ConditionalFilter(video, A, B, "AverageLuma(A)", ">", "AverageLuma(B)")
Subtitle("hello world!", align = 5)
use this:
A2 = StackHorizontal(A.Subtitle("hello world!", align = 5), B)
B2 = StackHorizontal(A, B.Subtitle("hello world!", align = 5))
ConditionalFilter(video, A2, B2, "AverageLuma(A)", ">", "AverageLuma(B)")

thus choosing the desired result for each frame.