3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
14 def ts2mkv(pin, pout, opt):
15 dir=os.path.split(pout)[0]
16 title=os.path.split(pout)[1]
17 title=os.path.splitext(title)[0]
18 tpavi=os.path.join(dir,title+".avi")
19 tpmkv=os.path.join(dir, title+".mkv")
20 tv2avi.ts2avi(pin, tpavi, opt)
22 avi2mkv(tpavi,tpmkv,opt)
23 def avi2mkv(pin,pout,opt):
24 dir=os.path.split(pout)[0]
25 title=os.path.split(pout)[1]
26 title=os.path.splitext(title)[0]
28 if re.search("v", opt):
30 if re.search("d",opt):
32 elif re.search("5",opt):
34 exe = configreader.getpath("mkvmerge")
36 os.environ['LANG']="ja_JP.UTF-8"
38 wineexe=configreader.getpath("wine")
39 cfr2tc=configreader.getpath("cfr2tc")
40 cap2ass=configreader.getpath("Caption2Ass")
41 pin120=pin.replace(".avi",".120.avi")
42 pints=pin.replace(".avi",".ts")
43 pintimecode=pin.replace(".avi",".timecode.txt")
44 pincap=pin.replace(".avi",".srt")
45 pinaac=pin.replace(".avi",".aac")
46 e0="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"
47 e1=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
48 e2=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
49 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"
50 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"
54 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
58 if (not os.path.exists(pin.replace(".avi",".120.avi"))and (not os.path.exists(pout))):
59 txt=txt+"CFR2TC error. maybe avi file is over 1GB.(ODML error would have happend.)"
60 ptmp=pin.replace(".avi",".noodml.avi")
61 e1="mencoder -noodml -forceidx -oac copy -ovc copy -o \'"+ptmp+"\'"+" \'"+pin+"\'"
62 e2=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+ptmp+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
63 e3=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
64 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"
65 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"
67 cmdt=cmdt+execcomd(e2)
68 cmdt=cmdt+execcomd(e3)
69 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
79 wineexe=configreader.getpath("wine")
80 pincap=pin.replace(".avi",".srt")
81 cap2ass=configreader.getpath("Caption2Ass")
82 pints=pin.replace(".avi",".ts")
83 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
84 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"
85 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"
87 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
91 logo=pout.replace(".mkv",".log")
92 if status.getSettings_auto_del_tmp()==1:
94 txt = "\n####mkvmerge-log####\n"+txt
96 f.write(txt.encode('utf-8'))
100 cmdt=u"nice -n 17 "+cmd
102 txt=u"Cmd : "+cmd+"\n"
103 txt2=commands.getoutput(cmdt.encode('utf-8'))
104 txt=txt+unicode(txt2,"utf-8")+"\n"
108 def deltitle(path,title):
110 dp.append(os.path.join(path,title+".avi"))
111 dp.append(os.path.join(path,title+".120.avi"))
112 dp.append(os.path.join(path,title+".noodml.avi"))
113 dp.append(os.path.join(path,title+".aac"))
114 dp.append(os.path.join(path,title+".srt"))
115 if os.path.exists(os.path.join(path,title+".ts"))and os.path.exists(os.path.join(path,title+".ts.b25")):
116 if os.path.getsize(os.path.join(path,title+".ts"))*10>os.path.getsize(os.path.join(path,title+".ts.b25")):
117 if os.path.getsize(os.path.join(path,title+".ts"))>1000*1000*100:
118 dp.append(os.path.join(path,title+".ts.b25"))