shindigo
26th February 2007, 05:21
Hi -
I've been working on scripts that analyze frames. In most case I want to write information about frames that have certain properties to a text file and show the number of frames found so far with those properties as a subtitle on the source video.
The form of these scripts is like this test script:
# FrameEvalTest
c = BlankClip(length=19, color=color_white, pixel_type="YV12")
b = BlankClip(length=1, color=color_black, pixel_type="YV12")
c = c + b + c + b + c + b
global writeFrame = false
global numBlack = 0
global c2 = c.ReduceBy2.Greyscale
c2 = c2.ScriptClip("subtitle(string(numBlack), align=3)") # this shows how many so far.
c2 = c2.WriteFileIf("FrameEvalTest.txt", "(writeFrame)", "numBlack = numBlack + 1", "current_frame") # this does the counting and logging.
c2 = c2.FrameEvaluate("writeFrame = (AverageLuma <= 16.5)") # this will be some long calculation and condition.
return c2
This works fine (it counts the number of black frames in the video)
But, I have been trying to figure out how to do the calculations on the reduced video, but have the ScriptClip subtitle show on the original video.
I have tried replacing c2 = c2.ScriptClip(... with c = c.ScriptClip(... and returning c, but it never increments the numBlack counter.
Also, why does it never count the final black frame?
TIA
sh-
I've been working on scripts that analyze frames. In most case I want to write information about frames that have certain properties to a text file and show the number of frames found so far with those properties as a subtitle on the source video.
The form of these scripts is like this test script:
# FrameEvalTest
c = BlankClip(length=19, color=color_white, pixel_type="YV12")
b = BlankClip(length=1, color=color_black, pixel_type="YV12")
c = c + b + c + b + c + b
global writeFrame = false
global numBlack = 0
global c2 = c.ReduceBy2.Greyscale
c2 = c2.ScriptClip("subtitle(string(numBlack), align=3)") # this shows how many so far.
c2 = c2.WriteFileIf("FrameEvalTest.txt", "(writeFrame)", "numBlack = numBlack + 1", "current_frame") # this does the counting and logging.
c2 = c2.FrameEvaluate("writeFrame = (AverageLuma <= 16.5)") # this will be some long calculation and condition.
return c2
This works fine (it counts the number of black frames in the video)
But, I have been trying to figure out how to do the calculations on the reduced video, but have the ScriptClip subtitle show on the original video.
I have tried replacing c2 = c2.ScriptClip(... with c = c.ScriptClip(... and returning c, but it never increments the numBlack counter.
Also, why does it never count the final black frame?
TIA
sh-