View Full Version : Animate: decrease smoothness (evaluate only every 6 frames)
Kadano
10th September 2014, 16:33
Hello. I’ve been using Avisynth for a few months to explain slow-motion gameplay. Now I want to add a frame strip viewer that scrolls horizontally. The problem is that I only show 5 gameplay frames per second (ChangeFPS((…5),30), and I want to scroll the frame strip only by one symbol per gameplay frame, or every sixth video frame.
Here’s a screenshot of the frame strip so you can make sense of what I’m squabbling:
http://i.imgur.com/sg5CN5g.png
I want the ↓ arrow to stay at the same position, with the frame strip abruptly scrolling left by one symbol length (20px).
As it is now, the Animate function moves the frame strip by ~4 px on every video frame, which looks really weird and not exact considering the gameplay frames change that infrequently by comparison.
Do you have an idea how I could make this work?
creaothceann
10th September 2014, 17:22
Something like this:
function Draw_Arrow(clip c, int x, int y) {
x = x - (x % 6)
# ...
}
Add offsets as needed.
Kadano
10th September 2014, 21:11
Something like this:
function Draw_Arrow(clip c, int x, int y) {
x = x - (x % 6)
# ...
}
Add offsets as needed.
I don’t understand. How do I call base_clip that way? And how does the % help? I read in the documentation that it stands for mod, but I don’t get why I’d want to use mod?
Also, what is “# …”? What else do I need?
Sorry that I’m so dumb.
foxyshadis
10th September 2014, 23:24
The formula quantizes x to multiples of six. "mod" means remainder, so x will go from 0, 1, 2, 3, 4, 5, 6, 7... to 0, 0, 0, 0, 0, 0, 6, 6... It's equivalent to x = int(x/6) * 6, but faster.
You work something like that into whatever arrow drawing function you use, where it figures out how far to advance for each frame, to make it skip forward the way you want. It all depends on how you draw the arrow, so if you want specific help, you're going to have to show your complete current code.
creaothceann
10th September 2014, 23:32
"base_clip"?
You'd do it like this:
# starting position of the arrow
global arrow_xpos = 40
global arrow_ypos = 300
################################################################
# source video (in this case just an info screen)
BlankClip(length=500, width=640, height=360, pixel_type="RGB32", fps=60).KillAudio.Info
# the Animate call (makes the parameter i essentially a frame counter)
Animate(0, FrameCount - 1, "Draw_Arrow", 0, FrameCount - 1)
function Draw_Arrow(clip c, int i) {
c
# make i "jump" in 6-frame-increments
i = i - (i % 6)
# replace SubTitle with your actual arrow drawing code
Subtitle("V", arrow_xpos + i, arrow_ypos, text_color=$FFFFFF)
}
EDIT: what foxyshadis said
Kadano
11th September 2014, 00:16
Am I supposed to just copy this in like this?:
# starting position of the arrow
global arrow_xpos = 100
global arrow_ypos = 300
################################################################
# source video (in this case just an info screen)
BlankClip(length=500, width=640, height=360, pixel_type="RGB32", fps=60).KillAudio.Info
# the Animate call (makes the parameter i essentially a frame counter)
Animate(0, FrameCount - 1, "Draw_Arrow", 0, FrameCount - 1)
function Draw_Arrow(clip c, int i) {
c
# make i "jump" in 6-frame-increments
i = i - (i % 6)
# replace SubTitle with your actual arrow drawing code
Subtitle("V", arrow_xpos + i, arrow_ypos, text_color=$FFFFFF)
}
clip0=Draw_Arrow(fra20,20)
clip1=s5.Layer(clip0,"add",256,20,20)
clip1
s5 is a black clip. fra20 is the layer I want to add and move.
Doing it like this does overlay the clip, but it doesn’t move. Did I misunderstand you?
creaothceann
11th September 2014, 08:29
Read the comments in the code... With your setup it'd be more like this:
s5 = s5 .ConvertToRGB32
fra20 = fra20.ConvertToRGB32
Animate(0, FrameCount - 1, "Draw_Arrow", fra20, 0, fra20, FrameCount - 1)
function Draw_Arrow(clip c, clip o, int i) {
arrow_xpos = 40 # adjust these to your liking
arrow_ypos = 300
i = i - (i % 6)
Layer(c, o, x=arrow_xpos + i, y=arrow_ypos)
}
If your clips are not in RGB colorspace (http://avisynth.nl/index.php/RGB) (e.g. you captured the video from an actual console) then remove the "ConvertToRGB32" lines and replace "Layer" with "Overlay".
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.