TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua
标题:
[SAI]034_hyoukaOP2
[打印本页]
作者:
saiyaku
时间:
2012-8-24 19:58:19
标题:
[SAI]034_hyoukaOP2
預覽:
http://pan.baidu.com/s/1hqqY9CC#dir/path=%2FSaiyakuFX_Preview
關於頻譜算法 表示我是參考needlessED2 和 paniponiED
看著看著 算法就出來了。。。
from tcaxPy import *
from util.tcAudio import *
SPECHEIGHT = 60
def tcaxPy_Init():
# some common pre-defined global values
global fontSize # as name implies
global resX # horizontal resolution
global resY # vertical resolution
global marginX # horizontal margin
global marginY # vertical margin
global spacing # space between texts
global frameDur # milliseconds per frame
global lineNum # number of lines
global textNum # textNum[i], number of texts in ith line
global _BT # _BT[i], start time of a line
global _ET # _ET[i], end time of a line
global _KT # _KT[i][j], karaoke time of a syllable
global _SK # _SK[i][j], elapsed karaoke time before reaching a certain syllable
global _TXT # _TXT[i][j], as name implies
global _L # _L[i], total width of a line
global _W # _W[i][j], width of a text
global _H # _H[i][j], height of a text
global _A # _A[i][j], advance of a text, usually larger than width
global _AD # _AD[i][j], distance between the current text to the first text of the line
fontSize = GetVal(val_FontSize)
resX = GetVal(val_ResolutionX)
resY = GetVal(val_ResolutionY)
marginX = GetVal(val_OffsetX)
marginY = GetVal(val_OffsetY)
spacing = GetVal(val_Spacing)
frameDur = 1000 / GetVal(val_FXFPS)
lineNum = GetVal(val_nLines)
textNum = GetVal(val_nTexts)
_BT = GetVal(val_BegTime)
_ET = GetVal(val_EndTime)
_KT = GetVal(val_KarTime)
_SK = GetVal(val_KarTimeDiff)
_TXT = GetVal(val_Text)
_L = GetVal(val_TextLength)
_W = GetVal(val_TextWidth)
_H = GetVal(val_TextHeight)
_A = GetVal(val_TextAdvance)
_AD = GetVal(val_TextAdvanceDiff)
def Spectrum(fft): # convert fft data to graph
bars = []
b0 = 0
for x in range(BANDS):
peak = 0 # peak of a certain bar
b1 = pow(2, x * 10.0 / (BANDS - 1))
if b1 > 1023:
b1 = 1023
if b1 <= b0:
b1 = b0 + 1 # make sure it uses at least 1 FFT bin
while b0 < b1:
if peak < fft[1 + b0]:
peak = fft[1 + b0]
b0 += 1
y = int(sqrt(peak) * 3 * SPECHEIGHT - 4) # scale it (sqrt to make low values more visible)
if y > SPECHEIGHT:
y = SPECHEIGHT # cap it
bars.append(y)
return bars
def tcaxPy_User():
file_name = GetVal(val_OutFile) + '.ass'
ass_header = GetVal(val_AssHeader)
ASS_FILE = CreateAssFile(file_name, ass_header)
tcAudioInit()
channel = tcAudioOpen('h.mp3')
freq = tcAudioGetFreq(channel) # usually 44100 Hz
duration = tcAudioGetDuration(channel)
num = int(duration * freq / 2048)
F = []
for k in range(num):
fft = tcAudioGetFFT(channel, 2048)
F.append(fft)
for i in range(lineNum):
initPosX = (resX - _L[i]) / 2 + marginX # if marginX = 0, then it's just on the middle
initPosY = 720- marginY
SPECWIDTH = _L[i] +50
global BANDS
BANDS = int(SPECWIDTH/5)
for a in range(num):
ASS_BUF = []
bars = Spectrum(F[a])
bar_width = SPECWIDTH/BANDS
count = len(bars)
P = []
for b in range(count):
start = a * 100 * 2048 / freq
end = (a + 1) * 100 * 2048 / freq
x = (1280 - SPECWIDTH) / 2 + bar_width * b+25
y = initPosY-20
if b < count -1:
if bars[b]>bars[b+1] :
if bars[b]>30:
bars[b] = 30
if b%2 == 0:
P.append((x,y+bars[b]))
else:
P.append((x,y-bars[b]))
if P != [] and start > _BT[i] and end <_ET[i]+10:
sb = '{\p1}m '+str(int((1280 - SPECWIDTH) / 2))+' '+str(int(y))+' l '+str(int((1280 - SPECWIDTH) / 2)+25)+' '+str(int(y)) +' '+' '.join('l '+str(int(p[0]))+' '+str(int(p[1])) for p in P)+' l '+str(int((1280 - SPECWIDTH) / 2+_L[i])+50)+' '+str(int(y))
TP = P[::-1]
sb = sb+' l '+str(int((1280 - SPECWIDTH) / 2+_L[i])+50)+' '+str(int(y-1)) +' ' +' '.join('l '+ str(int(tp[0]))+' '+str(int(tp[1])-1) for tp in TP)+' l '+str(int((1280 - SPECWIDTH) / 2)+25)+' '+str(int(y-1)) +' l '+str(int((1280 - SPECWIDTH) / 2))+' '+str(int(y-1))
ass_main(ASS_BUF, SubL(start, end, 1, Pix_Style), an(7) +alpha(0)+color1('000000')+bord(1)+color3('000000') +shad(1)+color4('FFFFFF') + pos(0, 0) , sb)
WriteAssFile(ASS_FILE, ASS_BUF)
for j in range(textNum[i]):
COLOR =["7A90FF","49D297","CDAF50"]
CLR1 = color1("FFFFFF")+color3("000000") + alpha1(0)
ASS_BUF = []
if _TXT[i][j] == '' or _TXT[i][j] == ' ' or _TXT[i][j] == ' ':
continue
posX = initPosX + _AD[i][j] + _A[i][j] / 2
posY = initPosY - 19
ass_main(ASS_BUF, SubL(_BT[i]+_SK[i][j]+_KT[i][j], _ET[i]+j*5, 200),fad(0,200)+ an(5) + pos(posX, posY) + CLR1+bord(1.8)+shad(1.5) ,_TXT[i][j] )
ass_main(ASS_BUF, SubL(_BT[i]+_SK[i][j]-10, _BT[i]+_SK[i][j]+_KT[i][j], 200), an(5) + pos(posX, posY)+t(0,15,fsc(135,135)) +t(100,_KT[i][j]*10,fsc(100,100))+bord(1.8)+ CLR1 , _TXT[i][j])
if i>9:
if j == 0:
nposX = posX - 40
else:
nposX = initPosX + _AD[i][j-1] + _A[i][j-1] / 2
for q in range(3):
C = COLOR[q]
CLR2 = color1(C)
POS = Bezier3( _KT[i][j],nposX,posY,posX, posY,posX+randint(-50,50), posY+randint(-75,75),posX+randint(-50,50), posY+randint(-75,75))
for w in range(_KT[i][j]):
ass_main(ASS_BUF, SubL(_BT[i]+_SK[i][j]-20+w*1, _BT[i]+_SK[i][j]-20+(w+1)*1,151), an(5)+bord(0)+frz(60)+shad(0)+color3(C)+color1("00FFFF")+blur(0.8) + pos(POS[w][0], POS[w][1])+fs(10), "★")
ass_main(ASS_BUF, SubL(_BT[i]+_SK[i][j]-20+w*1, _BT[i]+_SK[i][j]-20+50+(w+1)*1,150-w), fad(50,300)+an(5)+blur(1.8)+bord(0)+shad(0)+CLR2 +t(fsc(int(280),int(50*100/_KT[i][j])))+ pos(POS[w][0], POS[w][1])+fs(5), "■")
WriteAssFile(ASS_FILE, ASS_BUF) # write the buffer in memory to the file
Progress(i,j)
tcAudioFin()
FinAssFile(ASS_FILE)
复制代码
作者:
渣渣疯子
时间:
2012-8-24 20:03:11
一如既往的...看不太懂
作者:
milkyjing
时间:
2012-8-24 20:21:01
一上来就看到灾厄连撸三发...
作者:
アクマ
时间:
2016-7-11 13:37:44
码一个 回家继续啃
作者:
Seekladoom
时间:
2022-1-17 00:55:41
本帖最后由 Seekladoom 于 2022-1-17 01:01 编辑
已对sai大脚本进行1080P化修改,请将下列压缩包都下好后再一起解压:
TCAX Karaoke Effect Kinesis.part1.rar
(950 KB, 下载次数: 2525)
2022-1-17 00:55:23 上传
下载次数: 2525
TCAX Karaoke Effect Kinesis.part2.rar
(950 KB, 下载次数: 2487)
2022-1-17 00:55:28 上传
下载次数: 2487
TCAX Karaoke Effect Kinesis.part3.rar
(950 KB, 下载次数: 2491)
2022-1-17 00:55:32 上传
下载次数: 2491
TCAX Karaoke Effect Kinesis.part4.rar
(241.14 KB, 下载次数: 2364)
2022-1-17 00:55:36 上传
下载次数: 2364
在线预览:
【音频可视化-特效测试】两个世界的超能力者
附件:
TCAX Karaoke Effect Kinesis.part4.rar
(2022-1-17 00:55:36, 241.14 KB) / 下载次数 2364
http://tcax.org/forum.php?mod=attachment&aid=Mjg1NHw0NzY4YmQ5OXwxNzMyMjM4MDg4fDB8MA%3D%3D
附件:
TCAX Karaoke Effect Kinesis.part3.rar
(2022-1-17 00:55:32, 950 KB) / 下载次数 2491
http://tcax.org/forum.php?mod=attachment&aid=Mjg1M3xhZTVhNWFkNXwxNzMyMjM4MDg4fDB8MA%3D%3D
附件:
TCAX Karaoke Effect Kinesis.part2.rar
(2022-1-17 00:55:28, 950 KB) / 下载次数 2487
http://tcax.org/forum.php?mod=attachment&aid=Mjg1MnxhNjE3OTM4OXwxNzMyMjM4MDg4fDB8MA%3D%3D
附件:
TCAX Karaoke Effect Kinesis.part1.rar
(2022-1-17 00:55:23, 950 KB) / 下载次数 2525
http://tcax.org/forum.php?mod=attachment&aid=Mjg1MXxhMTQyZTRiMnwxNzMyMjM4MDg4fDB8MA%3D%3D
欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/)
Powered by Discuz! X2