Last active
December 5, 2020 08:22
-
-
Save tana3n/7706ce2bcfc8a69b880b410ec55275b8 to your computer and use it in GitHub Desktop.
周期不定vfrなavs用タイムコード生成Macro for AvsP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### GetTimecode v0.3 by tana3n | |
### Date:2020-12-05 | |
### ChangeLog | |
### v0.3 2020-12-05 Trim([0-9]+.0)形式での記述時に対する対応の強化 | |
import os | |
import re | |
filename = avsp.GetScriptFilename(propose='general') | |
scripts = avsp.GetText() | |
timecode = str(re.sub(r'avs','',filename) + "tmc") | |
analysis = re.sub(r'^Trim.+\..+\n','',scripts,flags=(re.IGNORECASE|re.MULTILINE)) | |
with open(timecode,"w") as tmc: | |
#ここで逆テレシネ処理部分を抽出 | |
test=re.findall(r'^Trim.+\..+$',scripts,flags=(re.IGNORECASE|re.MULTILINE)) | |
tmc.write('# timecode format v1\n# GetTimecode v0.3[2020-12-05] by tana3n\nAssume 119.88011988\n') | |
startf=0 | |
endf=-1 | |
#ソースのフレームレート取得 処理前のを拾わないと正常に処理が出来ない | |
avsp.NewTab() | |
avsp.InsertText(analysis,pos=-1) | |
originalfps = avsp.GetVideoFramerate() | |
avsp.CloseTab() | |
for s in test: | |
avsp.NewTab() | |
avsp.HideVideoWindow() | |
avsp.InsertText(analysis,pos=-1) | |
s2=re.sub(r'\+\\','',s) | |
avsp.InsertText("\n"+s2,pos=-1) | |
end=avsp.GetVideoFramecount() | |
endf+=end | |
oriframe=re.findall(r'Trim\([0-9]+,[0-9]+\)',s,flags=re.IGNORECASE)[-1] | |
oriframe2=re.findall(r'[0-9]+',oriframe) | |
oristart=int(oriframe2[0]) | |
oriend=int(oriframe2[1]) | |
if oriend == 0: | |
sp2=re.findall(r'^^Trim.+$',analysis,flags=(re.IGNORECASE|re.MULTILINE)) | |
if sp2 !=[]: | |
sp1=re.findall(r'[0-9]+',str(sp2[0])) | |
oriend=int(sp1[1])-int(sp1[0]) | |
avsp.MsgBox('Detected! last' + str(oriend) +' last:'+ str(sp1[1]) + " start:" + str(sp1[0])) | |
else: | |
fixframe = re.findall(r'Trim\([0-9]+,[0-9]+\)',s,flags=re.IGNORECASE)[0] | |
fixframe = re.findall(r'[0-9]+',fixframe) | |
oriend = int(fixframe[1])-int(fixframe[0]) | |
ends=oriend-oristart+1 | |
newfps=originalfps*end/ends | |
tmc.write(str(startf) + ',' + str(endf) + "," + str(newfps) + ' \n') | |
startf=endf+1 | |
avsp.CloseTab() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment