TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua
标题:
TCAX視頻處理模塊tcVideo Beta版發佈
[打印本页]
作者:
saiyaku
时间:
2014-5-2 01:22:03
标题:
TCAX視頻處理模塊tcVideo Beta版發佈
說明
使用該模塊 獲取視頻信息 分辨率顏色透明度之類
使用方法: 解壓後 將tcVideo文件夾 複製進tcax程序目錄下 util文件夾內
py編寫時 開頭追加 from util.tcVideo import * 即可
用法 見附帶例子 test_video py內有詳細注釋 (執行腳本前 複製一個任意視頻進工作目錄 改名為test.mp4 )
模塊下載地址:
http://pan.baidu.com/s/1ntoIUfR
test_video.zip
(2.12 KB, 下载次数: 2084)
2014-5-2 01:16:56 上传
下载次数: 2084
附件:
test_video.zip
(2014-5-2 01:16:56, 2.12 KB) / 下载次数 2084
http://tcax.org/forum.php?mod=attachment&aid=MTcyMnw3M2I5YWU4NXwxNzMyMjA3MzkyfDB8MA%3D%3D
作者:
milkyjing
时间:
2014-5-2 22:15:51
顶起, 下(you)个(sheng)版(zhi)本(nian)包含这个升级
作者:
lilight
时间:
2014-5-3 10:11:29
milkyjing 发表于 2014-5-2 22:15
顶起, 下(you)个(sheng)版(zhi)本(nian)包含这个升级
突然想说一句,奶大节哀
作者:
兜兜里没糖
时间:
2014-5-3 20:40:40
milkyjing 发表于 2014-5-2 22:15
顶起, 下(you)个(sheng)版(zhi)本(nian)包含这个升级
233
作者:
萨默尔
时间:
2014-6-30 08:33:32
还不清楚怎么用,先看看
作者:
Sky℃
时间:
2014-11-7 23:58:32
milkyjing 发表于 2014-5-2 22:15
顶起, 下(you)个(sheng)版(zhi)本(nian)包含这个升级
大大 你这话说的 (-。-;)
作者:
Seekladoom
时间:
2022-1-26 01:51:05
本帖最后由 Seekladoom 于 2022-1-26 22:11 编辑
milkyjing 发表于 2014-5-2 22:15
顶起, 下(you)个(sheng)版(zhi)本(nian)包含这个升级
真成有生之年了。。。
楼主度盘下不了的朋友看这里,分卷下好后一起解压即可到tcVideo模块:
tcVideo.part1.rar
(950 KB, 下载次数: 1727)
2022-1-26 03:09:24 上传
下载次数: 1727
tcVideo.part2.rar
(950 KB, 下载次数: 1694)
2022-1-26 03:09:33 上传
下载次数: 1694
tcVideo.part3.rar
(797.06 KB, 下载次数: 1718)
2022-1-26 03:09:38 上传
下载次数: 1718
from tcaxPy import *
from util.tcVideo import *
def tcaxPy_User():
file_name = GetVal(val_OutFile) + '.ass'
ass_header = GetVal(val_AssHeader)
ASS_FILE = CreateAssFile(file_name, ass_header)
fx_fps = GetVal(val_FXFPS)
ASS_BUF = []
tcVideoInit() # 初始化
video = tcVideoOpen('test.mp4') # 載入視頻
print(tcVideoGetProps(video)) # tcVideoGetProps()獲取屏幕分辨率
tcVideoSetRes(video, 848, 480) # 縮放
print(tcVideoGetProps(video)) # 還是獲取分辨率
PIX = tcVideoGetFrame(video, 100) # 獲取第100幀的畫面像素信息 返回一個PIX結構(和粒子字是一樣的)
SavePix(abspath('screenshot1.png'), PIX) # 沒什麼用 輸出圖片
PIX = tcVideoGetFrameByTime(video, 100 / fx_fps) # 按時間獲取
SavePix(abspath('screenshot2.png'), PIX)
tcVideoSetRes(video, 1280, 720)
for i in range(1000):
r, g, b, a = tcVideoGetFrameColor(video, i) #獲取第i幀 顏色(平均值)基本一點用都沒有
clr = FmtRGB(r, g, b)
ass_main(ASS_BUF, SubL(i * 100 / fx_fps, (i + 1) * 100 / fx_fps), pos(100, 100) + color1(clr) + color3("0000FF") + bord(2) + alpha(0), 'R') # alpha(255-a) 可以調用alpha值 這邊例子為了充分顯示顏色 不加透明度
r2, g2, b2, a2 = tcVideoGetFramePosColor(video, i,1100,620) #取第i幀 (1100,620)坐標的顏色
clr2 = FmtRGB(r2, g2, b2)
ass_main(ASS_BUF, SubL(i * 100 / fx_fps, (i + 1) * 100 / fx_fps), pos(1100, 620) + color1(clr2) + color3("0000FF")+ bord(2) + alpha(0), 'H')
r3, g3, b3, a3 = tcVideoGetFrameRectColor(video, i,590,310,690,410) #取第i幀 區域方塊顏色的中值 (590,310) 是區域左上角坐標 (690,410)為區域右下角坐標 因為還是用排序來取中值 如果設置範圍太大 運算效率會很低 我姑且測試了一下 (0,0)到(1280,720) i5 CPU 4G內存 1000幀用了 近300秒
clr3 = FmtRGB(r3, g3, b3)
ass_main(ASS_BUF, SubL(i * 100 / fx_fps, (i + 1) * 100 / fx_fps), pos(640, 360) + color1(clr3) + color3("0000FF") + bord(2) + alpha(0), '日')
progress(i + 1, 1000)
WriteAssFile(ASS_FILE, ASS_BUF)
tcVideoClose(video)
tcVideoFin()
FinAssFile(ASS_FILE)
##############################################
def tcas():
file_name = GetVal(val_OutFile) + '.tcas'
fx_width = GetVal(val_ResolutionX)
fx_height = GetVal(val_ResolutionY)
fx_fps = GetVal(val_FXFPS)
TCAS_FILE = CreateTcasFile(file_name, fx_width, fx_height, fx_fps)
TCAS_BUF = []
tcas_main(...)
WriteTcasFile(TCAS_FILE, TCAS_BUF)
FinTcasFile(TCAS_FILE)
def ass():
file_name = GetVal(val_OutFile) + '.ass'
ass_header = GetVal(val_AssHeader)
ASS_FILE = CreateAssFile(file_name, ass_header)
ASS_BUF = []
fx_fps = GetVal(val_FXFPS)
FinAssFile(ASS_FILE)
复制代码
附件:
tcVideo.part3.rar
(2022-1-26 03:09:38, 797.06 KB) / 下载次数 1718
http://tcax.org/forum.php?mod=attachment&aid=Mjg2NHxiN2FjYmI5NXwxNzMyMjA3MzkyfDB8MA%3D%3D
附件:
tcVideo.part2.rar
(2022-1-26 03:09:33, 950 KB) / 下载次数 1694
http://tcax.org/forum.php?mod=attachment&aid=Mjg2M3xkZmZlMTEzNXwxNzMyMjA3MzkyfDB8MA%3D%3D
附件:
tcVideo.part1.rar
(2022-1-26 03:09:24, 950 KB) / 下载次数 1727
http://tcax.org/forum.php?mod=attachment&aid=Mjg2MnwxY2I1MmNlMXwxNzMyMjA3MzkyfDB8MA%3D%3D
作者:
Seekladoom
时间:
2022-1-26 03:11:59
本帖最后由 Seekladoom 于 2022-1-26 03:13 编辑
居然是用def tcaxPy_User写的,试试看能不能改成
def tcaxPy_Init的格式并运行。
作者:
Seekladoom
时间:
2022-1-29 04:26:19
本帖最后由 Seekladoom 于 2022-1-29 04:27 编辑
传个能跑的脚本:
【tcVideo】TCAX Karaoke Effect test.rar
(7.2 KB, 下载次数: 1622)
2022-1-29 04:26:16 上传
下载次数: 1622
from tcaxPy import *
from util.tcVideo import *
def tcaxPy_Init():
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)
global _FD
global _Fs
global Font
global fx_fps
_FD = 1000 / GetVal(val_FXFPS)
_Fs = GetVal(val_FontSize)
Font = InitFont(GetVal(val_FontFileName), GetVal(val_FaceID), _Fs, GetVal(val_Spacing), GetVal(val_SpaceScale), 0xFFFFFF, 0, 0)
fx_fps = GetVal(val_FXFPS)
def tcaxPy_Fin():
FinFont(Font)
def tcaxPy_User():
# 创建ASS文件
file_name = GetVal(val_OutFile) + '.ass'
ass_header = GetVal(val_AssHeader)
ASS_FILE = CreateAssFile(file_name, ass_header)
fx_fps = GetVal(val_FXFPS)
ASS_BUF = []
# tcVideo
tcVideoInit() # 初始化
video = tcVideoOpen('mekakucityactors_NCED.mp4') # 載入視頻
print(tcVideoGetProps(video)) # tcVideoGetProps()獲取屏幕分辨率
tcVideoSetRes(video, 1920, 1080) # 縮放
print(tcVideoGetProps(video)) # 還是獲取分辨率
PIX = tcVideoGetFrame(video, 100) # 獲取第100幀的畫面像素信息 返回一個PIX結構(和粒子字是一樣的)
SavePix(abspath('screenshot1.png'), PIX) # 沒什麼用 輸出圖片
PIX = tcVideoGetFrameByTime(video, 100 / fx_fps) # 按時間獲取
SavePix(abspath('screenshot2.png'), PIX)
tcVideoSetRes(video, 1920, 1080)
for i in range(lineNum):
initPosX = marginX + (resX - _L[i]) / 2 # an 7, 4, 1
initPosY = marginY # an 7, 8, 9
for j in range(textNum[i]):
if _TXT[i][j] == '' or _TXT[i][j] == ' ' or _TXT[i][j] == ' ':
continue
t0 = _BT[i] - 15 + j * 7
t1 = t0 + 50
frames = int((_ET[i] - 60 - t1) * 10 / _FD + 0.5)
# an 2
DX = initPosX + _AD[i][j] + _A[i][j] / 2
DY = initPosY + resY - 44
for c in range(frames):
r, g, b, a = tcVideoGetFrameRectColor(video,c,0,1000,1920,1065) #取第c帧区域矩形颜色的中值(1100,620)坐標的顏色
clr = FmtRGB(r, g, b)
ass_main(ASS_BUF, SubL(c * 100 / fx_fps,(c + 1) * 100 / fx_fps), pos(DX, DY) + color1(clr) + color3("0000FF") + bord(2) + alpha(0), _TXT[i][j])
progress(c + 1, 2208)
WriteAssFile(ASS_FILE, ASS_BUF)
tcVideoClose(video)
tcVideoFin()
FinAssFile(ASS_FILE)
复制代码
附件:
【tcVideo】TCAX Karaoke Effect test.rar
(2022-1-29 04:26:16, 7.2 KB) / 下载次数 1622
http://tcax.org/forum.php?mod=attachment&aid=Mjg2OXxiMjliYjQ3M3wxNzMyMjA3MzkyfDB8MA%3D%3D
欢迎光临 TCAX 字幕特效制作工具官方论坛 | ASS | TCAS | Python | Aegisub | Lua (http://tcax.org/)
Powered by Discuz! X2