Log in

View Full Version : Width and Num


pbreak
19th August 2013, 05:32
Hi

I'd like to change the Num generator based on the width of the video, how can i make this script work?

Width <= 1200 ? Eval("""
S = V.SVSuper("{rc:false,gpu:1, scale:{up:2, down:2}}")
A = S.SVAnalyse("{main:{coarse:{distance:-1, bad:{SAD:20}}},penalty:{pzero:1,pnbour:1000}}, refine:[{thsad:20}]}")
V.SVSmoothFps(S, A, "{rate:{num:50000,den:1001,abs:true},algo:21, mask:{area:30,cover:100,area_sharp:1.0},scene:{blend:false,mode:0,limits:{blocks:100}}}", url=URL, mt=100)
GetMTMode(false) > 0 ? distributor()
"""): last
Width > 1200 ? Eval("""
S = V.SVSuper("{rc:false,gpu:1, scale:{up:2, down:2}}")
A = S.SVAnalyse("{main:{coarse:{distance:-1, bad:{SAD:20}}},penalty:{pzero:1,pnbour:1000}}, refine:[{thsad:20}]}")
V.SVSmoothFps(S, A, "{rate:{num:60000,den:1001,abs:true},algo:21, mask:{area:30,cover:100,area_sharp:1.0},scene:{blend:false,mode:0,limits:{blocks:100}}}", url=URL, mt=100)
GetMTMode(false) > 0 ? distributor()
"""): last

I added V = V.Width, and i get an error saying there is ":" missing, so i change ": last" and i put after "distributor()" ... but nothing seems to work.


Thanks

wonkey_monkey
19th August 2013, 09:40
I added V = V.Width

Do you mean you added:

Width = V.Width

?

I got the same error about a missing :, but only when I didn't have SVPflow installed - after that I got other errors about OpenCL so I didn't investigate much further.

Doing two exclusive tests on Width seems a bit wasteful - you could just do:

Width > 1200 ? Eval("""...""") : Eval("""...""")

But as the only thing changing is the num: in SVSmoothFps, why not try just setting a string based on the width and build the rest of your script around that? (unless of course this is just an example and you're planning on doing something much more complicated...)

Off the top of my head, and not tested due to lack of plugins:

mynum = V.width <= 1200 ? "50000" : "60000"

S = V.SVSuper("{rc:false,gpu:1, scale:{up:2, down:2}}")
A = S.SVAnalyse("{main:{coarse:{distance:-1, bad:{SAD:20}}},penalty:{pzero:1,pnbour:1000}}, refine:[{thsad:20}]}")
V.SVSmoothFps(S, A, "{rate:{num:" + mynum + ",den:1001,abs:true},algo:21, mask:{area:30,cover:100,area_sharp:1.0},scene:{blend:false,mode:0,limits:{blocks:100}}}", url=URL, mt=100)
GetMTMode(false) > 0 ? distributor() : last


David

Gavino
19th August 2013, 09:47
You can simplify the code to this:
num = Width <= 1200 ? 50000 : 60000
S = V.SVSuper("{rc:false,gpu:1, scale:{up:2, down:2}}")
A = S.SVAnalyse("{main:{coarse:{distance:-1, bad:{SAD:20}}},penalty:{pzero:1,pnbour:1000}}, refine:[{thsad:20}]}")
V.SVSmoothFps(S, A, "{rate:{num:"+String(num)+",den:1001,abs:true},algo:21, mask:{area:30,cover:100,area_sharp:1.0},scene:{blend:false,mode:0,limits:{blocks:100}}}", url=URL, mt=100)
GetMTMode(false) > 0 ? distributor() : last

EDIT: Ah, davidhorman beat me to it, but his final line is wrong - should be
GetMTMode(false) > 0 ? distributor() : last

pbreak
19th August 2013, 13:20
davidhorman and Gavino

Thank you guys, you're awesome.
It's working.