View Full Version : How to display the minute counter only (solved)
hanfrunz
21st December 2009, 14:55
Hello everyone,
i'd like to add a small counter to a video which shows the actual minute of the film and the length (example 12 of 90 min.) I can get the duration using Framecount/Framerate/60, but how can i get the actual position of a clip.
Maybe it's very easy, but i can't find it... Or do i have to create a filter for that using subclip() internally?
hanfrunz
StainlessS
21st December 2009, 15:02
int(Framecount/Framerate/60.0)
floor(Framecount/Framerate/60.0)
I think that shoud do it, give it a try (I have not)
hanfrunz
21st December 2009, 15:15
that only gives me the length, but i need the actual position...
Guest
21st December 2009, 15:21
Write a simple plugin to do it. Each plugin receives the frame number in its GetFrame() function.
hanfrunz
21st December 2009, 15:27
i think i found a way using something like this: (from avisynth docs)
# Shows the frame-number in a clip:
ScriptClip("subtitle(string(current_frame))")
i'll test
StainlessS
21st December 2009, 15:30
It does indeed show the current frame, but how would you extract it a a variable.
EDIT:
tried below and it works
ScriptClip("subtitle(string(int(current_frame/Framerate/60.0)))")
Guest
21st December 2009, 15:32
current_frame is the variable, presumably.
hanfrunz
21st December 2009, 15:35
In my case i wanted to use subtitle anyway. But how can i append another string to "string(current_frame)". I need something like string1+string2. Is there a function to append two strings?
LaTo
21st December 2009, 15:38
In my case i wanted to use subtitle anyway. But how can i append another string to "string(current_frame)". I need something like string1+string2. Is there a function to append two strings?
Yes: string1+string2 :devil:
StainlessS
21st December 2009, 15:42
string2=" string2"
ScriptClip("subtitle( string(int(current_frame/Framerate/60.0)) + STRING2)")
hanfrunz
21st December 2009, 15:44
Oh i see my problem was, that i wrote:
ScriptClip("subtitle("something"+ string(int(current_frame/framerate/60)))")
too much of these """ ... what can i do except of using mytest="something" and then mytest + ...?
LaTo
21st December 2009, 15:49
Oh i see my problem was, that i wrote:
ScriptClip("subtitle("something"+ string(int(current_frame/framerate/60)))")
ScriptClip("""subtitle("something"+ string(int(current_frame/framerate/60)))""")
hanfrunz
21st December 2009, 15:54
great here is my final script:
colorbars(720,576)
ScriptClip("""subtitle(string(1+int(current_frame/framerate/60))+" of " +string(1+int(framecount/framerate/60))+" minutes")""")
thanks to everyone, i learned my lesson of string operations today ;)
StainlessS
21st December 2009, 15:59
Got to make a note of that, its very well hidden under "ConditionalFilter"
Gavino
22nd December 2009, 12:13
Got to make a note of that, its very well hidden under "ConditionalFilter"
Start reading here:
http://avisynth.org/mediawiki/Runtime_environment
StainlessS
25th December 2009, 21:03
@ Gavino, Ta, Got to read that a few more times.
See Below, Just a few little snips connected with this thread,
implemented as functions, really only to self document them.
(Seconds not properley formatted, comes out as
0.12 instead of 00.12)
Function HoursMinutesSeconds(Clip Last)
{ # "%02.xf" for fractional seconds where:- x=0 None,1=tenths,2=hundredths,3=thousandths
ScriptClip("""subtitle( \
string(int(current_frame/FrameRate/3600))+ ":" + \
string((int(current_frame/FrameRate/60) % 60),"%02.0f") + ":" + \
string((int(current_frame/FrameRate*10000) % 600000)/10000.0,"%02.3f") \
)""")
}
Function MinutesSeconds(Clip Last)
{ # "%02.xf" for fractional seconds where:- x=0 None,1=tenths,2=hundredths,3=thousandths
ScriptClip("""subtitle( \
string((int(current_frame/FrameRate/60) % 60),"%02.0f") + ":" + \
string((int(current_frame/FrameRate*10000) % 600000)/10000.0,"%02.0f") \
)""")
}
Function Seconds(Clip Last)
{ # "%0.xf" for fractional seconds where:- x=0 None,1=tenths,2=hundredths,3=thousandths
ScriptClip("""subtitle( \
string(current_frame/FrameRate,"%0.3f") \
)""")
}
Function Frames(Clip Last)
{
ScriptClip("subtitle(string(current_frame))")
}
Function Frames2(Clip Last)
{
ScriptClip("""subtitle("Frame " + string(current_frame))""")
}
Function Message(clip Last,string Message)
{
GLOBAL GLB_MESSAGE_TEXT=Message
ScriptClip("""subtitle(GLB_MESSAGE_TEXT + string(current_frame))""")
}
Gavino
26th December 2009, 13:55
GLOBAL GLB_MESSAGE_TEXT=Message
ScriptClip("""subtitle(GLB_MESSAGE_TEXT + string(current_frame))""")
You can get rid of the global variable (which prevents you using the function more than once in the same script) by using GRunT. ;)
GScriptClip("""subtitle(Message + string(current_frame))""", args="Message")
StainlessS
26th December 2009, 16:16
@ Gavino,
Thanx, have downloaded Grunt, Am currently using 2.57, (went back from 2.58
as kept getting crash after Media player (F6) is closed,in AVSEdit. Crashes
disappear in 2.57,[In pretty much any script, may be connected to AVSEdit
rather than anything else]). As using 2.57, need to use eg GScriptClip rather
than ScriptClip, however, I do not find this any kind of burden, kinda like
having to use the language extended version as it is self documenting that
Grunt is required.
Would you know of any plugin that can tell the source of a particular
function, eg built-in, script or plugin. Had a script function "Difference()"
which worked just fine in main script, but when imported, is using something
else (which seems only to return the original clip). Perhaps, I should not ask
this, in this thread.
EDIT:- The Difference() plugin mentioned above is hidden in the SSETools.dll of RemoveGrain, Describe in below link.
SSETools (http://videoprocessing.11.forumer.com/viewtopic.php?t=30)
Gavino
26th December 2009, 19:17
Would you know of any plugin that can tell the source of a particular
function, eg built-in, script or plugin. Had a script function "Difference()"
which worked just fine in main script, but when imported, is using something
else (which seems only to return the original clip). Perhaps, I should not ask
this, in this thread.
I don't know of any way to find this out.
Post your two scripts in a new thread and perhaps we can spot what is going on.
StainlessS
27th December 2009, 00:22
@ Gavino,
Thankyou for your reply, Just thought a plugin that could query source would be
a good idea. Does not matter about the example given, have changed it anyway
to something that is unlikely to collide with any other plugin.
Anyways, thought you were going on holiday, you work too hard!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.