Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#2 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,479
|
Just curious, what do you want to use that for?
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
|
|
|
|
#4 | Link |
|
Registered User
Join Date: Nov 2005
Posts: 70
|
StainlessS and Gavino: THANKS for the response.
I guess I'm just lazy: while writing my own version of a kind of Clip_Info Function, I realized I was typing: Return Clip_Info(clip1, "clip1") and I just wondered is there a way to NOT need the separate String version of the clip name as the second argument.... |
|
|
|
|
|
#5 | Link |
|
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,444
|
There is nothing in a clip which associates it with a variable name, as with all variables the relation is strictly one-way, name -> value.
In any case, a clip might not be associated with a variable. What would you expect this to do? return Clip_info(ColorBars()) ??? HOWEVER, ... you could make the function take a string (rather than a clip) as its only parameter. Then the string could indicate the name and by Eval'ing the name you could recover the clip too. However, the variable would have to be global. Last edited by Gavino; 13th May 2013 at 17:55. |
|
|
|
|
|
#6 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,479
|
Not really the sort of thing that could be reliably implemented in a plugin, even if it could, the internal storage
lists/structures could change and break the plug, would need to be built into Avisynth itself. Maybe eval could be persuaded to assist, but is likely to be more awkward than the extra typing that you currently are accursed with. Arh, beaten again
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
|
|
|
|
|
#8 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,479
|
Here implemented as per Gavino post,
Code:
Global MyClip=Avisource("D:\avs\test.avi")
s=Test("MyClip")
Myclip.SubTitle(S,lsp=0)
return Last
Function Test(String s) {
c=Eval(s)
s = "Name ="+S+"\n"+ \
"Width ="+String(c.Width)+"\n"+ \
"Height="+String(c.Height)+"\n"+ \
"Length="+String(c.FrameCount)+"\n"
return s
}
Chr(10) instead of '\n', dependant upon purpose. EDIT: This also works but the clip name is purely a nicety for return string. Code:
Avisource("D:\avs\test.avi")
s=Test("MyClip")
SubTitle(S,lsp=0)
return Last
Function Test(clip c,String s) {
s = "Name ="+S+"\n"+ \
"Width ="+String(c.Width)+"\n"+ \
"Height="+String(c.Height)+"\n"+ \
"Length="+String(c.FrameCount)+"\n"
return s
}
Code:
FN="test.avi" DIR="D:\avs\"
Avisource(DIR+FN)
s=Test(FN)
SubTitle(S,lsp=0)
return Last
Function Test(clip c,String s) {
s = "Name ="+S+"\n"+ \
"Width ="+String(c.Width)+"\n"+ \
"Height="+String(c.Height)+"\n"+ \
"Length="+String(c.FrameCount)+"\n"
return s
}
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 13th May 2013 at 21:02. |
|
|
|
|
|
#9 | Link |
|
Registered User
Join Date: Nov 2005
Posts: 70
|
Got the example as per Gavino working!
I am not used to code like c=Eval(s) where I think variable c's type at that point is undetermined. simply writing c.Width further on, the thing is clearly interpreted as being a clip... Nevertheless, it'working!!! |
|
|
|
|
|
#10 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,479
|
or you could just enter
Code:
Function Test(String s) {
Eval(s)
s = "Name ="+S+"\n"+ \
"Width ="+String(Width)+"\n"+ \
"Height="+String(Height)+"\n"+ \
"Length="+String(FrameCount)+"\n"
return s
}
Code:
Function Test(String s) {
MyClip # assign Global to Last
s = "Name ="+S+"\n"+ \
"Width ="+String(Width)+"\n"+ \
"Height="+String(Height)+"\n"+ \
"Length="+String(FrameCount)+"\n"
return s
}
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 14th May 2013 at 13:32. |
|
|
|
|
|
#11 | Link | |
|
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,444
|
Quote:
If instead you wrote global myclop = 42 s = Test("myclop") c.width would produce an error inside the function as it would be trying to take the width of an integer. |
|
|
|
|
|
|
#12 | Link |
|
Registered User
Join Date: Nov 2005
Posts: 70
|
But.....
when I try to recover information from RunTime only functions, I get an error "only available in runtime environment". OK, so I invoke ScriptClip as follows: Code:
Global MyClip=....
return ClipStats("MyClip", 5.0)
Function ClipStats(String s, float thr)
{
c=Eval(s)
return c.ScriptClip("""String(RT_AverageLuma(c))+" | stdev= "+String(RT_YPlaneStDev(c))\
+"\nlumamed= "+String(RT_YPlaneMedian(c))+" | lumamax= "+String(RT_YPlaneMax(c, threshold=thr))\
+"\nlumamin= "+String(RT_YPlaneMin(c, threshold=thr)), size=15, x=0,y=0, lsp=0)""")
}
"I don't know what c is"... |
|
|
|
|
|
#13 | Link |
|
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,444
|
Since c is the input parameter to ScriptClip(), it becomes 'last' inside the run-time script, so instead of RT_AverageLuma(c), you can just write RT_AverageLuma().
I think you are also missing the call to Subtitle(), so your code should look like Code:
return c.ScriptClip("""Subtitle(String(RT_AverageLuma())+ ...
You can get round that by using GRunT and adding args="thr" to the ScriptClip call. Last edited by Gavino; 15th May 2013 at 12:40. |
|
|
|
![]() |
|
|