View Full Version : Brightest
Frank62
12th March 2022, 23:53
I wonder if there is a way to achieve this in pure Avisynth:
I have let's say 20 test-clips. I want to get (for each frame) the one of those clips which is the brightest, but then take the frame out of a corresponding clip of another 20 clips.
So I have clips:
a1 b1
a2 b2
a3 b3
a4 b4
. .
. .
. .
a20 b20
If let's say frame #100 in a12 is the brightest of all 20 a-frames #100, then I want to take frame #100 of clip b12.
Does anyone understand :scared: and has an idea how to do this? As always I wanted to log and do the logic outside, but maybe there is a pure avisynth way?
Arx1meD
13th March 2022, 06:57
There is an OutRange script to analyze the brightness level of a frame.
https://forum.doom9.org/showthread.php?p=1940595#post1940595
Frank62
13th March 2022, 11:24
Thanks, but this is not my goal. What I try to achieve is to find the brightest frame out of 20 clips and then get another, corresponding clip.
Ceppo
13th March 2022, 14:35
If I understood your request you could do it with a for loop + average luma if avisynth+ supports array for clips. I never used the array update so I don't know.
Frank62
13th March 2022, 16:42
Yes, one should think that it was quite easy. Simply use two nested loops, the inner one for the frames, the outer for the 20 clips, but somehow I have to use the runtime functionality to even use averageluma, and to get it for each of the clip's frame. The problem is that you have two dimensions.
I think I will try it with a loop, and put out 20 logs of averagelumas, the logic will be done in .net. :thanks: so far.
Ceppo
13th March 2022, 18:16
My understanding from a quick reading was that you needed to take the brightest frame of the 20 clips at the same index, so compare frame 0 of each clip and get the brightest. It seems I got it wrong.
Frank62
13th March 2022, 18:43
You are totally right. And then take the brightest of all frames 1, and then of 2 a. s. o all frames of all clips through. And to go through the frames you will need Conditional..., Scriptclip or something, or am I wrong with this?
But I already logged fine and all logs are already inside my new small tool... Just have to compare each other, do some smoothing and put out the best clip numbers for each frame.
Ceppo
13th March 2022, 19:59
srcArray = ... (I don't know the grammar)
index = 0
ScriptClip("""
for(i = 1; i < 20; ++i) (I forgot the grammar so C++ version)
{
if(AverageLuma(srcArray[index]) < AverageLuma(srcArray[i]))
{
index = i
}
}
srcArray[index]
""")
The code would look like that, you have to translate it since I forgot the grammar and is probably bugged somewhere since I'm writing on instinct.
That's if that what you want.
Frank62
13th March 2022, 21:34
This will give you ONE clip, if I get it right, the clip whose LAST frame is the brightest (or in your case the darkest). What I need is a mixed clip containing only the brightest frames.
But never mind, thanks a lot for your help, I am on a good way with doing it external. :thanks:
_Al_
16th March 2022, 00:46
python/vapoursynth?
#pyhon code, not php
import vapoursynth as vs
from vapoursynth import core
clip = core.lsmas.LibavSMASHSource(r'F:\video.mp4')
#array with a clips
a = [clip.std.Expr(['x 80 +','','']),
clip.std.Expr(['x 30 +','','']),
clip.std.Expr(['x 60 +','',''])]
#array with b clips (arrays created just for testing)
b = [clip,
clip.std.Expr(['x 30 -','','']),
clip.std.Expr(['x 60 -','',''])]
a = [clip.std.PlaneStats(plane=0, prop='Y') for clip in a]
def most_bright(n):
values = [clip.get_frame(n).props['YAverage'] for clip in a]
most_bright_index = values.index(max(values))
#print(most_bright_index)
return b[most_bright_index]
out = core.std.FrameEval(a[1], most_bright)
out.set_output()
Frank62
16th March 2022, 12:16
Thanks again, but I fear I cannot say much to this. In Vapoursynth I am totally new. But the problem meanwhile is solved anyway: Logged the brightnesses, did the logic in .net, that gave me a textfile, which I read with ConditionalReader.
But it was all in vain anyway, because my great idea doesn't work... :cool:
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.