Bezier curve like a snake

Discuss and get help for karaoke effect creation here

Bezier curve like a snake

Unread postby sonkun » Sun Apr 05, 2020 2:18 pm

Hello everyone.

I would like to make an effect that would give the impression that a snake is wrapped around the syllables and that it progresses as the color of the syllable changes, like the one below:
Image

So I used the Bezier function of pyointa2001 (thanks to him by the way) which I modify to obtain this:
Image

But there are several problems :
- the curve does not start well at the edge of the video
- at the beginning the curve is not well "curve"
- but above all, at the end, the effect does not stop at the end of the syllable

Could someone please help me.

Below the code I used an modified:
Code: Select all
function Bezier_Move(s_time,e_time,aftimg_dur,x_blur,y_blur,acl,...) a = {...} if (j == 1) then t1 = s_time t2 = e_time dur = t2-t1 accel = acl n = #a/2 for i = 1,n*2-1,2 do x[(i+1)/2] = a[i] end for i = 2, n*2,2 do y[i/2] = a[i] end c_t = 0 maxloop(2) f_t = 1/(dur/frame_dur) end afterimage_dur = aftimg_dur if (afterimage_dur < 0 ) then afterimage_dur = 0 end pos_x, pos_y = Bezier(n,x,y,c_t) n_t = c_t + f_t  n_x, n_y = Bezier(n,x,y,n_t) dist = math.sqrt(math.abs(n_x-pos_x)^2+math.abs(n_y-pos_y)^2) a_t =f_t*(max_space/dist) if (a_t > f_t) then a_t = f_t end n_t = c_t + a_t if (n_t < 1) then maxj = j + 1 end retime("presyl",t1+dur*(c_t^accel),afterimage_dur) t = c_t c_t = n_t return string.format("\\pos(%f,%f)",pos_x,pos_y) end

Code: Select all
function Bezier(n,x,y,t) p_x = 0 p_y = 0 for i = 1, n, 1 do p_y = p_y + y[i] * set_temp("bern",bernstein(i-1,n-1,t)) p_x = p_x + x[i] * temp.bern  end return p_x, p_y end

Code: Select all
function bernstein(i,n,t) return (factk(n) / (factk(i)*factk(n-i))) * (t^i) * ((1-t)^(n-i)) end

Code: Select all
function factk(n) k = 1 if (n > 1) then for i = 2, n, 1 do k = k * i end end return k end

Code: Select all
{!Bezier_Move((syl.i==1) and -500 or -line.kara[syl.i-1].duration,0,line.end_time-line.start_time-syl.start_time+200,math.random(-10,10),math.random(-10,30),1,(syl.i==1) and 0 or recall.xx,(syl.i==1) and $middle/2 or $middle,(syl.i==1) and -10 or $center/2+recall.xx/2,(syl.i==1) and $middle+46 or  $middle-((syl.i%2==0) and ($center-recall.xx) or -($center-recall.xx)),$center,$middle)!!remember("xx",$scenter)!!remember("yy",$smiddle)!\fad(0,200)\an5\be1\bord3\3a&HB1&\1a&HB1&\1c&H5ACF72&\3c&H00FFFF&\p1}m 0 0 l 2 0 l 2 2 l 0 2
sonkun
Comic Sans MS
Comic Sans MS
 
Posts: 4
Joined: Fri May 01, 2015 11:07 am

Re: Bezier curve like a snake

Unread postby LeSaint » Sun Apr 05, 2020 6:32 pm

Hello sonkun,

I'm glad to see that there's still people trying to create karaokes with aegisub. If you want to learn more, you can read these pages:

Karaoke templater: http://docs.aegisub.org/3.2/Automation/ ... Templater/
This describes some common variables that you use, along with how the templater works.
About the code environment, you can read this: http://docs.aegisub.org/3.2/Automation/ ... vironment/
especially the section about the retime function. Maybe that will help you with your timing problem

It seems that your timing problem is here because you used the first syllable to manage the first start movement of your line, so as a result, all your syllables are shifted by 1. You could use a 'template line' to define your animation before the first syllable, and after the next syllable. Read more about the karaoke templater to see how to work with template syl, template noblank notext, template line, code syl all, etc... That should help you understand what you're trying to do :)

Right now, without the actual script, I can't help you more than that, so you could consider posting your script here for more details.

Good luck with your template, feel free to ask more questions if needed.
LeSaint
User avatar
LeSaint
Moderator
Moderator
 
Posts: 264
Joined: Wed Feb 10, 2010 8:19 pm

Re: Bezier curve like a snake

Unread postby sonkun » Sun Apr 12, 2020 8:56 am

Hello LeSaint.

Thank you for your reply. I always use aegisub for my kara and my effects.

I tried to modify the script using your advice but it is very difficult and I was going crazy with the Bézier curve.

Finally I used "Kara Effector", a big automation script for aegisub, maybe you know it. I modified a bezier effect and here is the result:

Image

It is not perfect as I wanted because the "snake" is on the line and not the syllables but I think it will be ok.
sonkun
Comic Sans MS
Comic Sans MS
 
Posts: 4
Joined: Fri May 01, 2015 11:07 am

Re: Bezier curve like a snake

Unread postby LeSaint » Mon Apr 13, 2020 8:54 am

Hello,

No, I don't know Kara Effector :)

I've checked some of my old karaoke with bezier curves, and I used it for a leadin effect (duration = 400ms) with a shape moving through the line. It seems having is synchronized with the syllables isn't easy after all. If you want, you could share your old script based on karaoke templater, I could have a look on it to see if I can find a way to have it synchronized with syllables.

LeSaint
User avatar
LeSaint
Moderator
Moderator
 
Posts: 264
Joined: Wed Feb 10, 2010 8:19 pm

Re: Bezier curve like a snake

Unread postby sonkun » Tue Apr 14, 2020 6:38 am

Hello.

Thanks for your help.

Here a link to download the ass script :
https://www.mediafire.com/file/qjr9dzpf ... t.ass/file
sonkun
Comic Sans MS
Comic Sans MS
 
Posts: 4
Joined: Fri May 01, 2015 11:07 am


Return to Karaoke

Who is online

Users browsing this forum: No registered users and 3 guests