3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
13 def ts2mkv(pin, pout, opt):
14 dir=os.path.split(pout)[0]
15 title=os.path.split(pout)[1]
16 title=os.path.splitext(title)[0]
17 tpavi=os.path.join(dir,title+".avi")
18 tpmkv=os.path.join(dir, title+".mkv")
19 tv2avi.ts2avi(pin, tpavi, opt)
21 avi2mkv(tpavi,tpmkv,opt)
22 def avi2mkv(pin,pout,opt):
24 if re.search("v", opt):
26 exe = configreader.getpath("mkvmerge")
29 os.environ['LANG']="ja_JP.UTF-8"
31 wineexe=configreader.getpath("wine")
32 cfr2tc=configreader.getpath("cfr2tc")
33 cap2ass=configreader.getpath("Caption2Ass")
34 pin120=pin.replace(".avi",".120.avi")
35 pints=pin.replace(".avi",".ts")
36 pintimecode=pin.replace(".avi",".timecode.txt")
37 pincap=pin.replace(".avi",".srt")
38 pinaac=pin.replace(".avi",".aac")
39 e0="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"
40 e1=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
41 e2=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" Z:\\"+pincap+"\""
42 e3=exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
43 e3s=exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --forced-track 0:no -s 0 -D -A '"+pincap+"' --track-order 0:0,1:0,2:0"
44 #exes.append(exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
45 #exes.append(doexe = exe + u" -o '" + pout + u"' --cues 0:all --forced-track 0:no --default-duration 0:120000/1001fps -d 0 -A -S '" + pin + u"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
49 if os.path.exists(pincap):
53 if (not os.path.exists(pin.replace(".avi",".120.avi"))and (not os.path.exists(pout))):
54 txt=txt+"CFR2TC error. maybe avi file is over 1GB.(ODML error would have happend.)"
55 ptmp=pin.replace(".avi",".noodml.avi")
56 e1="mencoder -noodml -forceidx -oac copy -ovc copy -o \'"+ptmp+"\'"+" \'"+pin+"\'"
57 e2=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+ptmp+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
58 e3=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" Z:\\"+pincap+"\""
59 e4=exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
60 e4s=exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --forced-track 0:no -s 0 -D -A '"+pincap+"' --track-order 0:0,1:0,2:0"
61 recdblist.printutf8(e)
64 cmdt=cmdt+execcomd(e2)
65 cmdt=cmdt+execcomd(e3)
66 if os.path.exists(pincap):
73 wineexe=configreader.getpath("wine")
74 pincap=pin.replace(".avi",".srt")
75 cap2ass=configreader.getpath("Caption2Ass")
76 pints=pin.replace(".avi",".ts")
77 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" Z:\\"+pincap+"\""
78 e1=exe + u" -o '" + pout + u"' --forced-track 0:no --forced-track 1:no -a 1 -d 0 -S '" + pin + u"' --track-order 0:0,0:1"
79 e1s=exe + u" -o '" + pout + u"' --forced-track 0:no --forced-track 1:no -a 1 -d 0 -S '" + pin + u"' --forced-track 0:no -s 0 -A -D '"+pincap+"' --track-order 0:0,0:1,1:0"
81 if os.path.exists(pincap):
85 logo=pout.replace(".mkv",".log")
86 """if (isvfr==1 and (not os.path.exists(pin.replace(".avi",".120.avi"))) and (not os.path.exists(pout))):
88 exes.append(exe + u" -o '" + pout + u"' --cues 0:all --forced-track 0:no --default-duration 0:120000/1001fps -d 0 -A -S '" + pin + u"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
89 txt=txt+"120fps cfr exection\n"
91 recdblist.printutf8(e2)
93 txt=txt+unicode(commands.getoutput(e2.encode('utf-8')),'utf-8')
97 txt = "\n####mkvmerge-log####\n"+txt
99 f.write(txt.encode('utf-8'))
103 cmdt=u"nice -n 17 "+cmd
105 txt=u"Cmd : "+cmd+"\n"
106 txt2=commands.getoutput(cmdt.encode('utf-8'))
107 txt=txt+unicode(txt2,"utf-8")+"\n"