『漫游』酷论坛>『DVDRip技术研修室』>因为被抓去压air, 所以 ..
因为被抓去压air, 所以............一个省力的工具..........
skywalker@2005-05-09 03:32
如题...............
工具的基本作用就是拿到一个timecode和vfr mkv里面demux出来的东西后..........
读那个timecode文件, 然后生出一个work.AVS........
里面会把时间段都分好, 然后只需要读那个avi再填上要加的filter和字幕就行了................
至于语言用的是python script...........
所以下一个python 后把后面贴的script当文本文件保存到一个xxx.py的文件里, 放到timecode的目录里双击运行就行了............
注意time code要是time.txt...............
成品样版:
##############################
#file source and filter here
##############################
import("I:\aviutl\filters.avs")
avisource("vid.avi")
lanczosresize(856,480)
deen("a3d",1,4,4)
undot()
##############################
# Splitting
##############################
part1= trim(0,2134).selectevery(1,0,0,0,0,0).assumefps(119.88)
part2= trim(2135,4829).selectevery(1,0,0,0,0).assumefps(119.88)
part3= trim(4830,32424).selectevery(1,0,0,0,0,0).assumefps(119.88)
part4= trim(32425,35122).selectevery(1,0,0,0,0).assumefps(119.88)
part5= trim(35123,35841).selectevery(1,0,0,0,0,0).assumefps(119.88)
work = part1+ part2+ part3+ part4+ part5
##############################
# Subbing
# Apply filter on clip work
##############################
work = work.textsub(op.ass)
work = work.textsub(ed.ass)
work = work.textsub(blahblah.ass)
##############################
# Combining
##############################
part1 = work.trim(0,10674).selectevery(5,0).assumefps(23.976)
part2 = work.trim(10675,21454).selectevery(4,0).assumefps(23.976)
part3 = work.trim(21455,159429).selectevery(5,0).assumefps(23.976)
part4 = work.trim(159430,170221).selectevery(4,0).assumefps(23.976)
part5 = work.trim(170222,173816).selectevery(5,0).assumefps(23.976)
last = part1+ part2+ part3+ part4+ part5
return last
python script:
############################
#globals constant
#######################
FPS24 = 23.976
FPS30 = 29.97
FPS60 = 29.97*2
FPS120 = 29.97*4
MINDIFF = 0.1
############################
#globals constant string
############################
SPLIT = "# Splitting\n"
SUBB = "# Subbing\n# Apply filter on clip work\n"
COMBB = "# Combining\n"
FIL = "#file source and filter here\n"
SEPRA = "##############################\n"
############################
#utility functions
############################
def readFile(list):
#filename = raw_input("input your file name")
filename = "time.txt"
f = open(filename, 'r')
if f.read(20) != "# timecode format v1":
raise NameError, 'wrong format'
f.readline()
f.readline()
for line in f:
#print len(line)
list.append(line.strip().split(','))
f.close()
def writeFile(list, list2):
prompt = ''
#filename = raw_input(prompt)
filename = "work.txt"
f = open(filename, 'w')
f.write(SEPRA)
f.write(FIL)
f.write(SEPRA)
tmp = "\n"*5
f.write(tmp)
f.write(SEPRA)
f.write(SPLIT)
f.write(SEPRA)
it = 1;
for sect in list:
tmp = "part" + str(it) + "= trim("+ sect[0]+","+sect[1]+")"+sect[3]+ ".assumefps(119.88)\n"
s = str(tmp)
f.write(s)
it = it + 1
f.write("work = ")
for i in range(1,len(list)):
tmp = "part" + str(i) + "+ "
f.write(tmp)
tmp = "part" + str(len(list)) + "\n"
f.write(tmp)
tmp = "\n"*2
f.write(tmp)
f.write(SEPRA)
f.write(SUBB)
f.write(SEPRA)
tmp = "\n"*5
f.write(tmp)
f.write(SEPRA)
f.write(COMBB)
f.write(SEPRA)
it = 1
for sect in list2:
tmp = "part" + str(it) + " = work.trim("
tmp = tmp + sect[0] + "," + sect[1] + ").selectevery("
tmp = tmp + str(sect[2]) + "," + "0"
tmp = tmp + ").assumefps(23.976)\n"
s = str(tmp)
f.write(s)
it = it + 1
f.write("last = ")
for i in range(1,len(list2)):
tmp = "part" + str(i) + "+ "
f.write(tmp)
tmp = "part" + str(len(list2)) + "\n"
f.write(tmp)
tmp = "\n"*2
f.write(tmp)
f.write("return last")
f.close()
#######################
#main function
#######################
sectionLists = []
finalList = []
readFile(sectionLists)
#find out the FPS of the sections
#only support 24/30/60 FPS types
for sect in sectionLists:
if abs(float(sect[2]) - FPS24) < MINDIFF:
sect.append(".selectevery(1,0,0,0,0,0)")
sect.append(5)
elif abs(float(sect[2]) - FPS30) < MINDIFF:
sect.append(".selectevery(1,0,0,0,0)")
sect.append(4)
elif abs(float(sect[2]) - FPS60) < MINDIFF:
sect.append(".selectevery(1,0,0)")
sect.append(2)
#find out the cutoff point to recover original video stream
tmpa = sectionLists[0][0]
tmpb = str((int(sectionLists[0][1]) + 1) * sectionLists[0][4] - 1)
finalList.append([tmpa, tmpb, sectionLists[0][4]])
for i in range(1,len(sectionLists)):
tmpa = str(int(finalList[i-1][1]) + 1)
tmp = int(sectionLists[1]) - int(sectionLists[i-1][1])
tmp = tmp * sectionLists[4]
tmp = tmp + int(finalList[i-1][1])
tmpb = str(tmp)
tmp2 = sectionLists[4]
finalList.append([tmpa, tmpb, tmp2])
writeFile(sectionLists, finalList)
wolfsoft@2005-05-09 21:00
python<==这是什么东西?= =|||
还是拿C++编译一下比较好,额外安装那些东西总是不爽
skywalker@2005-05-09 22:51
因为我觉得python用起来比c++有趣多了............
python的介绍: http://en.wikipedia.org/wiki/Python_programming_language
其实装一个也不麻烦, 大不了当计算器来用.............
而且这也不是什么古怪的东西, gmail也是用这个的...............
| TOP