- UID
- 2546
- 积分
- 159
- 帖子
- 30
- 主题
- 5
- 论坛币
- 868
- 威望
- 0
- EP值
- 134
- MP值
- 0
- 阅读权限
- 50
- 注册时间
- 2015-5-9
- 在线时间
- 52 小时
- 最后登录
- 2024-10-20
|
本帖最后由 Seekladoom 于 2022-1-26 22:11 编辑
milkyjing 发表于 2014-5-2 22:15
顶起, 下(you)个(sheng)版(zhi)本(nian)包含这个升级
真成有生之年了。。。
楼主度盘下不了的朋友看这里,分卷下好后一起解压即可到tcVideo模块:
tcVideo.part1.rar
(950 KB, 下载次数: 1736)
tcVideo.part2.rar
(950 KB, 下载次数: 1703)
tcVideo.part3.rar
(797.06 KB, 下载次数: 1723)
- 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)
复制代码 |
|