TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua
标题:
个人设想中的TCAX GUI生成的带python脚本代码的ASS字幕文件
[打印本页]
作者:
Seekladoom
时间:
2021-7-21 09:46:14
标题:
个人设想中的TCAX GUI生成的带python脚本代码的ASS字幕文件
本帖最后由 Seekladoom 于 2021-7-21 11:02 编辑
这个是我自己设想的一种带Python脚本代码的ASS字幕文件,第27行那里的[Python]表示ass字幕文件中的Python脚本代码分区,这部分内容我是打算如果未来有空给TCAX做GUI的话,就在GUI上加入一个专门写Python脚本代码的分区,并且这个分区的代码可以直接写入ass字幕文件(从外部加载py脚本生成特效的做法依然保留)。
做得出来的话当然是最好的,做不出来的话这个帖子也能给人留下一种TCAX GUI开发的思维方向了。。。_(:з」∠)_
[Script Info]
; Script generated by TCAX 1.2.0
; http://www.tcax.org/
ScriptType: v4.00+
Original Timing:
PlayResX: 1920
PlayResY: 1080
YCbCr Matrix: TV.709
[TCAX Project Garbage]
Audio File: ../../TCAX 1.2.0/../罪恶王冠 NCOP2.mp4
Video File: ../../TCAX 1.2.0/../罪恶王冠 NCOP2.mp4
Video AR Mode: 4
Video AR Value: 1.777778
Video Zoom Percent: 0.375000
Scroll Position: 18
Active Line: 21
Video Position: 1327
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: OPJP,FOT-Comet Std B,80,&H001F20EF,&H00000000,&H00FFFFFF,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,0,0,0,1
Style: OPJP2,FOT-Comet Std B,80,&H00FFBC11,&H00000000,&H00FFFFFF,&H00000000,0,0,0,0,100,100,0,0,1,2,0,8,0,0,0,1
Style: OPCN,MZhiHei PRC UltraBold,66,&H00FFFFFF,&H00000000,&H001F20EF,&H00000000,0,0,0,0,85,100,8,0,1,2,0,2,0,0,15,1
Style: OPCN2,MZhiHei PRC UltraBold,66,&H00FFFFFF,&H00000000,&H00FFBC11,&H00000000,0,0,0,0,85,100,8,0,1,2,0,2,0,0,15,1
[Python]
from tcaxPy import *
def tcaxPy_Init():
global _FD # frame duration, in millisecond
global _Blur, _Bord
global _FS
_FD = 1000 / GetVal(val_FXFPS)
_Blur = GetVal(val_Blur)
_Bord = GetVal(val_Bord)
_FS = GetVal(val_FontSize)
def tcaxPy_Fin():
pass
def tcaxPy_Main(_i, _j, _n, _start, _end, _elapk, _k, _x, _y, _a, _txt):
ASS_BUF = [] # used for saving ASS FX lines
# ----------tcax line----------
hexagon = 'm -6 -10 l 6 -10 l 12 0 l 6 10 l -6 10 l -12 0 l -6 -10 '
hlist = []
able = []
f = 10
initx = int(GetVal(5) // 2 - _n / 2 * _FS - 55)
lastx = int(GetVal(5) // 2 + _n / 2 * _FS + 55)
inity = int(_y - _FS)
for x in range(initx - f * 1 , lastx + _a + f * 2, f * 2):
for y in range(inity - f * 0, _y + _FS + f * 1, f):
hlist.append((x, y))
for x in range(initx - f * 2 , lastx + _a + f * 1, f * 2):
for y in range(inity - f // 2 - f * 0, _y + _FS - f // 2 + f * 1, f):
hlist.append((x, y))
for (px, py) in hlist:
if (px - _x) ** 2 + (py - _y) ** 2 <= 30 ** 2:
able.append((px, py))
count = int(_k * 1.6)
for i in range(count):
pt = choice(able)
px = pt[0]
py = pt[1]
st = randint(_start + _elapk - 10, _start + _elapk + _k)
et = st + randint(55, 75)
if st >= _start + _elapk + _k - 5:
et = st + randint(70, 100)
dur = et - st - 10
transp = 50
# ----------绘图代码行----------
if _i < 6:#OPJP
ass_main(ASS_BUF, SubL(st, et, 0, 'OPJP'), pos(px, py+45) + color3('FFFFFF') + color1('1F20EF') + alpha1(255) + alpha3(transp) + bord(1) + fad(100, dur * 10) + fsc(45, 45) + p(1), hexagon)
ass_main(ASS_BUF, SubL(st, et, 0, 'OPJP'), pos(px, py+45) + color3('FFFFFF') + color1('1F20EF') + alpha1(100) + alpha3(transp) + bord(1) + fad(100, dur * 10) + fsc(52, 52) + p(1), hexagon)
if _i > 5 and _i < 12:#OPJP2
ass_main(ASS_BUF, SubL(st, et, 0, 'OPJP2'), pos(px, py+45) + color3('FFFFFF') + color1('FFBC11') + alpha1(255) + alpha3(transp) + bord(1) + fad(100, dur * 10) + fsc(45, 45) + p(1), hexagon)
ass_main(ASS_BUF, SubL(st, et, 0, 'OPJP2'), pos(px, py+45) + color3('FFFFFF') + color1('FFBC11') + alpha1(100) + alpha3(transp) + bord(1) + fad(100, dur * 10) + fsc(52, 52) + p(1), hexagon)
# ----------文本行----------
if _i < 6:#OPJP
ass_main(ASS_BUF, SubL(_start+_j*3-20,_start+_elapk,1,'OPJP'), pos(_x,_y)+blur(4)+fad(200,0), _txt) #入场特效 - start2syl
ass_main(ASS_BUF, SubL(_start+_elapk,_start+_elapk+_k,1,'OPJP'), pos(_x,_y)+t(color1('FFFFFF')+color3('1F20EF'))+blur(4), _txt) #卡拉OK特效 - syl
ass_main(ASS_BUF, SubL(_start+_elapk+_k,_end-(_n-_j-1)*3+20,1,'OPJP'), pos(_x,_y)+color1('FFFFFF')+color3('1F20EF')+blur(4)+fad(0,200), _txt) #退场特效 - syl2end
if _i > 5 and _i < 12:#OPJP2
ass_main(ASS_BUF, SubL(_start+_j*3-20,_start+_elapk,1,'OPJP2'), pos(_x,_y)+color1('FFBC11')+color3('FFFFFF')+blur(4)+fad(200,0), _txt) #入场特效 - start2syl
ass_main(ASS_BUF, SubL(_start+_elapk,_start+_elapk+_k,1,'OPJP2'), pos(_x,_y)+color1('FFBC11')+color3('FFFFFF')+t(color1('FFFFFF')+color3('FFBC11'))+blur(4), _txt) #卡拉OK特效 - syl
ass_main(ASS_BUF, SubL(_start+_elapk+_k,_end-(_n-_j-1)*3+20,1,'OPJP2'), pos(_x,_y)+color1('FFFFFF')+color3('FFBC11')+blur(4)+fad(0,200), _txt) #退场特效 - syl2end
if _i > 11 and _i < 18:#OPCN
ass_main(ASS_BUF, SubL(_start+_j*3-20,_end-(_n-_j-1)*3+20,1,'OPCN'), pos(_x,_y+1068)+blur(4)+fad(200,200)+fax(-0.11), _txt) #整体特效 - line
if _i > 17:#OPCN2
ass_main(ASS_BUF, SubL(_start+_j*3-20,_end-(_n-_j-1)*3+20,1,'OPCN2'), pos(_x,_y+1068)+blur(4)+fad(200,200)+fax(-0.11), _txt) #整体特效 - line
return (ASS_BUF, None)
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,--------------------OPJP--------------------
Dialogue: 0,0:00:07.36,0:00:15.35,OPJP,,0,0,0,,{\k34}崩{\k56}壊{\k87}の{\k28}{\k41}交{\k53}響{\k34}曲{\k33}が{\k39}鳴{\k29}り{\k40}響{\k31}い{\k294}て
Dialogue: 0,0:00:18.50,0:00:25.85,OPJP,,0,0,0,,{\k31}降{\k43}る{\k95}雨{\k42}{\k37}は{\k35}ま{\k20}る{\k34}で{\k101}涙{\k37}の{\k32}音{\k228}色
Dialogue: 0,0:00:27.69,0:00:29.04,OPJP,,0,0,0,,{\k22}気{\k26}付{\k30}い{\k57}て
Dialogue: 0,0:00:29.12,0:00:34.18,OPJP,,0,0,0,,{\k22}そ{\k34}の{\k19}目{\k27}は{\k76}互{\k37}い{\k36}を{\k53}認{\k84}め{\k18}る{\k20}た{\k80}め
Dialogue: 0,0:00:34.70,0:00:39.92,OPJP,,0,0,0,,{\k25}そ{\k35}の{\k50}声{\k44}は{\k62}想{\k32}い{\k33}を{\k34}伝{\k75}え{\k18}る{\k13}た{\k101}め
Dialogue: 0,0:00:40.30,0:00:49.85,OPJP,,0,0,0,,{\k20}そ{\k30}の{\k20}手{\k40}は{\k25}大{\k55}事{\k35}な{\k51}人{\k25}と{\k95}繋{\k145}ぐ{\k0} {\k21}た{\k224}め{\k15}に{\k15}あ{\k175}る
Dialogue: 0,0:00:50.25,0:00:53.95,OPJP2,,0,0,0,,{\k74}こ{\k68}の{\k68}歌{\k28}が{\k43}聴{\k15}こ{\k22}え{\k18}て{\k34}る
Dialogue: 0,0:00:54.30,0:00:57.56,OPJP2,,0,0,0,,{\k17}生{\k69}命{\k35}あ{\k26}る{\k43}全{\k19}て{\k29}の{\k40}者{\k48}よ
Dialogue: 0,0:00:57.90,0:01:02.18,OPJP2,,0,0,0,,{\k73}真{\k64}実{\k63}は{\k15}あ{\k18}な{\k17}た{\k18}の{\k48}胸{\k21}の{\k41}中{\k15}に{\k15}あ{\k20}る
Dialogue: 0,0:01:02.48,0:01:05.20,OPJP2,,0,0,0,,{\k55}嵐{\k39}の{\k46}海{\k13}を{\k17}行{\k18}く{\k25}時{\k59}も
Dialogue: 0,0:01:05.47,0:01:11.45,OPJP2,,0,0,0,,{\k23}决{\k29}し{\k38}て{\k24}臆{\k25}す{\k18}る{\k18}こ{\k15}と{\k20}の{\k15}な{\k16}い{\k31}強{\k18}さ{\k308}を
Dialogue: 0,0:01:13.12,0:01:17.47,OPJP2,,0,0,0,,{\k27}く{\k29}れ{\k13}る{\k87}か{\k279}ら
Comment: 0,0:00:00.00,0:00:00.00,Default,,0,0,0,,--------------------OPCN--------------------
Dialogue: 0,0:00:07.36,0:00:15.35,OPCN,,0,0,0,,{\k73}崩{\k73}溃{\k73}的{\k73}交{\k73}响{\k73}乐{\k73}章{\k73}在{\k73}响{\k73}彻{\k73}着
Dialogue: 0,0:00:18.50,0:00:25.85,OPCN,,0,0,0,,{\k67}狂{\k67}乱{\k67}的{\k67}雨{\k67}仿{\k67}佛{\k67}眼{\k67}泪{\k67}的{\k67}音{\k67}色
Dialogue: 0,0:00:27.69,0:00:29.04,OPCN,,0,0,0,,{\k45}醒{\k45}来{\k45}吧
Dialogue: 0,0:00:29.12,0:00:34.18,OPCN,,0,0,0,,{\k51}那{\k51}双{\k51}眼{\k51}是{\k51}为{\k51}了{\k51}承{\k51}认{\k51}彼{\k51}此
Dialogue: 0,0:00:34.70,0:00:39.92,OPCN,,0,0,0,,{\k52}那{\k52}声{\k52}音{\k52}是{\k52}为{\k52}了{\k52}传{\k52}达{\k52}思{\k52}念
Dialogue: 0,0:00:40.30,0:00:49.85,OPCN,,0,0,0,,{\k80}那{\k80}双{\k80}手{\k80}是{\k80}为{\k80}了{\k80}握{\k80}紧{\k80}重{\k80}要{\k80}的{\k80}人
Dialogue: 0,0:00:50.25,0:00:53.95,OPCN2,,0,0,0,,{\k62}能{\k62}听{\k62}见{\k62}这{\k62}首{\k62}歌
Dialogue: 0,0:00:54.30,0:00:57.56,OPCN2,,0,0,0,,{\k65}万{\k65}物{\k65}生{\k65}灵{\k65}啊
Dialogue: 0,0:00:57.90,0:01:02.18,OPCN2,,0,0,0,,{\k61}真{\k61}相{\k61}在{\k61}你{\k61}的{\k61}心{\k61}中
Dialogue: 0,0:01:02.48,0:01:05.20,OPCN2,,0,0,0,,{\k34}教{\k34}会{\k34}我{\k34}真{\k34}正{\k34}的{\k34}坚{\k34}强
Dialogue: 0,0:01:05.47,0:01:11.45,OPCN2,,0,0,0,,{\k66}就{\k66}算{\k66}在{\k66}暴{\k66}风{\k66}雨{\k66}中{\k66}航{\k66}行
Dialogue: 0,0:01:13.12,0:01:17.47,OPCN2,,0,0,0,,{\k87}也{\k87}绝{\k87}不{\k87}胆{\k87}怯
复制代码
之所以这么想,是因为以前刚做字幕时到处找带特效模板的ass文件以及用Aegisub时养成的习惯——在Aegisub界面下的ass字幕文件中写好特效模板,然后点击一下应用卡拉OK模板即可生成ASS特效字幕的便利感。
在看过Aegisub和TCAX的github源码外加对ass字幕文件中的内容观察后,我才发现这两个软件生成ASS特效字幕时都是在字幕文件中有
一段段文本分区
的,且这些文本分区都在软件中有相应的
依靠自定义字符串批量生成文本
的脚本文件。文本分区如下:
--------------------Aegisub的是--------------------
[Script Info]
[Aegisub Project Garbage]
[V4+ Styles]
[Events]
--------------------TCAX的是--------------------
[Script Info]
[V4+ Styles]
[Events]
这也是我会想到在ASS字幕文件中添加[Python]的文本代码分区的原因之一,如果Aegisub当初那批老外开发时是这么设计(写个[Lua]或者[AUTO4]分区)的话,也就不至于把代码写进[Events]分区中因无法换行而挤作一团,导致代码阅读性不友好了。。。_(:з」∠)_
欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/)
Powered by Discuz! X2