View Full Version : Printing variables on video
`Orum
29th January 2016, 21:05
I'm working on a script and would find it terribly useful to print various values onto the video frame from AviSynth's internal functions. For example, here's my naïve attempt:
Subtitle(YDifferenceFromPrevious(last).String())
...which results in an error of: "Plane Difference: This filter can only be used within run-time filters." Looking around I see that whenever these are used with more than just a simple comparison operator, people just tend to dump the value to a file and read it from there, but is there a simple way to draw the values on the video?
Also, somewhat related, is it possible to return a variable (not a video/audio clip, but int, float, etc.) from an external filter? Looking at the avisynth.h header, this doesn't seem possible short of just dumping the data to a file, but maybe I'm missing something.
StainlessS
29th January 2016, 21:32
This should probably be in Avisynth Usage Forum.
Colorbars.ConvertToYV12
ScriptClip("""Subtitle(YDifferenceFromPrevious(last).String())""")
is it possible to return a variable (not a video/audio clip, but int, float, etc.) from an external filter?
A filter returns a video clip, what is it that you are trying to do (ie return what to what)?
TheFluff
29th January 2016, 21:47
Functions exported from plugins can return any AVSValue-compatible type. If you can accept only being compatible with yourself you can also pretend env->NewVideoFrame() is malloc(), treat the video frame buffer as just another bit of memory and put whatever you want in a clip. (A surprising number of plugins actually do this, regardless of how terrible an idea it really is.)
`Orum
29th January 2016, 21:49
This should probably be in Avisynth Usage Forum.
Ah, sorry. Anyway, thanks for pointing me to ScriptClip, I've never used it before.
A filter returns a video clip, what is it that you are trying to do (ie return what to what)?
I'm writing a plugin that calculates a metric for use in other filters, and I was hoping I could just return this value--in this case, a double--and use that numeric value immediately in a script. From what I've seen all plugins that ever output something other than a frame just dump this into a file as it looks like you're forced to return a clip and not a variable.
That's fine and I can work around that, but it's inconvenient at best and error-prone at worst.
Edit: Thanks Fluff, that's probably the lesser of two evils in this case, though I can probably make it return only internal types for 99% of what I hope to do.
StainlessS
29th January 2016, 22:27
OK, then maybe OK in developer forum.
Suggest try look up "non clip function" in avisynth SDK docs, in avisynth install, need tick option to include extra files, or can
download Avisynth compressed help file (*chm) with sdk, in data folder in mediafire link in my sig below.
Edit: search "non-clip sample"
`Orum
29th January 2016, 23:14
Edit: search "non-clip sample*
Thanks, that's exactly what I needed! Now to get back to coding...
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.