Log in

View Full Version : WriteFile() problem, ColorYUV(analyze=True) result as plain text?


zee944
6th May 2010, 20:02
LoadPlugin("PlaneMinMax[0.3.0.19].dll") # for calculating average Y, U, V
AVISource("sample.avi")
ConvertToYV12

tweaked01=last.ColorYUV(off_y=-20, off_u=+12, off_v=-3)
tweaked02=last.ColorYUV(off_y=+11, off_u=+10, off_v=-11)
tweaked03=last.ColorYUV(off_y=+2, off_u=-2, off_v=-11)

tweaked01
last = PlaneUAvg("YAvg")
last = PlaneUAvg("UAvg")
last = PlaneVAvg("VAvg")
ScriptClip("""Subtitle("Yavg: "+String(YAvg)+"", x=48, y=110, text_color=$00FF00)""")
ScriptClip("""Subtitle("Uavg: "+String(UAvg)+"", x=48, y=130, text_color=$00FF00)""")
ScriptClip("""Subtitle("Vavg: "+String(VAvg)+"", x=48, y=150, text_color=$00FF00)""")
WriteFile("stat.txt", "Yavg", """ " #tweaked01 Y channel average" """, append=true)
WriteFile("stat.txt", "Uavg", """ " #tweaked01 U channel average" """, append=true)
WriteFile("stat.txt", "Vavg", """ " #tweaked01 V channel average" """, append=true)

tweaked02
last = PlaneUAvg("YAvg")
last = PlaneUAvg("UAvg")
last = PlaneVAvg("VAvg")
ScriptClip("""Subtitle("Yavg: "+String(YAvg)+"", x=48, y=110, text_color=$00FF00)""")
ScriptClip("""Subtitle("Uavg: "+String(UAvg)+"", x=48, y=130, text_color=$00FF00)""")
ScriptClip("""Subtitle("Vavg: "+String(VAvg)+"", x=48, y=150, text_color=$00FF00)""")
WriteFile("stat.txt", "Yavg", """ " #tweaked02 Y channel average" """, append=true)
WriteFile("stat.txt", "Uavg", """ " #tweaked02 U channel average" """, append=true)
WriteFile("stat.txt", "Vavg", """ " #tweaked02 V channel average" """, append=true)

tweaked03
last = PlaneUAvg("YAvg")
last = PlaneUAvg("UAvg")
last = PlaneVAvg("VAvg")
ScriptClip("""Subtitle("Yavg: "+String(YAvg)+"", x=48, y=110, text_color=$00FF00)""")
ScriptClip("""Subtitle("Uavg: "+String(UAvg)+"", x=48, y=130, text_color=$00FF00)""")
ScriptClip("""Subtitle("Vavg: "+String(VAvg)+"", x=48, y=150, text_color=$00FF00)""")
WriteFile("stat.txt", "Yavg", """ " #tweaked03 Y channel average" """, append=true)
WriteFile("stat.txt", "Uavg", """ " #tweaked03 U channel average" """, append=true)
WriteFile("stat.txt", "Vavg", """ " #tweaked03 V channel average" """, append=true)


I have different clips within an AviSynth script. I want to create statistics for all of them, calculating out the average Y, U, V values and put it into a text file. (Basically I want the same thing ColorYUV(analyze=True) shows me, but I need it as plain text data.)

The problem is that I can only save the statistics of ONE clip at the time. I want to save the data of all the three (or more) clips! In the example above, I try to save the statistics of tweaked01, tweaked02 and tweaked03. But only the results of 'tweaked01' is being put in stat.txt. Why? I can see that it's probably because I switch between video clips and only the last one which matters (only the last one will be displayed by the script too), but I've no idea for a workaround. Probably it would work if I could get the values with a function like RGBDifference() within the WriteFile line, but it doesn't seem to be possible. Perhaps it isn't possible with this PlaneMinMax plugin, but possible with something else? Please help! :confused:

wonkey_monkey
6th May 2010, 20:21
This doesn't answer your question, but did you mean to use PlaneUAvg twice?

last = PlaneUAvg("YAvg") # Shouldn't that be PlaneYAvg?
last = PlaneUAvg("UAvg")
last = PlaneVAvg("VAvg")


I can see that it's probably because I switch between video clips and only the last one which matters (only the last one will be displayed by the script too)

Isn't tweaked03 the last clip returned?

You could try assigning the end results of each section to a clip, then using stackhorizontal at the end to make sure they're all returned (and therefore that all paths of the script are processed).

David

Gavino
6th May 2010, 20:39
davidhorman's solution is correct. You could also use Interleave instead of StackHorizontal (this would be faster).

BTW Why are you using this plugin when you can just use AverageLuma, AverageChromaU and AverageChromaV directly with WriteFile?

zee944
10th May 2010, 01:22
This doesn't answer your question, but did you mean to use PlaneUAvg twice?

No, that was a typo indeed.

BTW Why are you using this plugin when you can just use AverageLuma, AverageChromaU and AverageChromaV directly with WriteFile?

Somewhere I've read it wouldn't work proberly and I've believed it. But now I've tried it again and it worked. Thank you for the help guys, everything's fine now :)