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]
29 if re.search("v", opt):
31 if re.search("d",opt):
34 elif re.search("5",opt):
36 exe = configreader.getpath("mkvmerge")
38 os.environ['LANG']="ja_JP.UTF-8"
40 wineexe=configreader.getpath("wine")
41 cap2ass=configreader.getpath("Caption2Ass")
42 pints=pin.replace(".avi",".ts")
43 pincap=pin.replace(".avi",".srt")
44 pinaac=pin.replace(".avi",".aac")
45 e0="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"
46 #e1=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
47 e2=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
48 #e3=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -A -S '"+pin+"' --sync 0:-100 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
49 #e3s=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -A -S '"+pin+"' --sync 0:-100 --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"
50 e3=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -a 1 -S '"+pin+"' --sync 0:0 --track-order 0:0,0:1"
51 e3s=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -a 1 -S '"+pin+"' --sync 0:0 --forced-track 0:no -s 0 -D -A '"+pincap+"' --track-order 0:0,0:1,1:0"
55 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
60 wineexe=configreader.getpath("wine")
61 pincap=pin.replace(".avi",".srt")
62 cap2ass=configreader.getpath("Caption2Ass")
63 pints=pin.replace(".avi",".ts")
64 paac1=pin.replace(".avi","_1.aac")
65 paac2=pin.replace(".avi","_2.aac")
66 recdblist.printutf8(paac1)
67 if not os.path.exists(paac1):
68 paac1=pin.replace(".avi","_1.mp3")
69 paac2=pin.replace(".avi","_2.mp3")
70 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
71 e1=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -A -S '"+pin+"' --sync 0:0 --forced-track 0:no -a 1 -D -S '"+paac1+"' --forced-track 0:no -a 1 -D -S '"+paac2+"' --track-order 0:0,1:1,2:1"
72 e1s=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -A -S '"+pin+"' --sync 0:0 --forced-track 0:no -a 1 -D -S '"+paac1+"' --forced-track 0:no -a 1 -D -S '"+paac2+"' --forced-track 0:no -s 0 -D -A '"+pincap+"' --track-order 0:0,1:1,2:1,3:0"
74 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 pinaac=pin.replace(".avi",".aac")
84 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
85 e1="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"
87 e2=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -A -S '"+pin+"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
88 e2s=exe +" -o '"+pout+u"' --forced-track 0:no -d 0 -A -S '"+pin+"' --sync 0:0 --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"
91 #e2=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"
92 #e2s=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"
95 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
99 logo=pout.replace(".mkv",".log")
100 if status.getSettings_auto_del_tmp()==1:
102 txt = "\n####mkvmerge-log####\n"+txt
104 f.write(txt.encode('utf-8'))
108 cmdt=u"nice -n 17 "+cmd
110 txt=u"Cmd : "+cmd+"\n"
111 txt2=commands.getoutput(cmdt.encode('utf-8'))
112 txt=txt+unicode(txt2,"utf-8")+"\n"
116 def deltitle(path,title):
118 dp.append(os.path.join(path,title+".avi"))
119 dp.append(os.path.join(path,title+".120.avi"))
120 dp.append(os.path.join(path,title+".noodml.avi"))
121 dp.append(os.path.join(path,title+".aac"))
122 dp.append(os.path.join(path,title+".m2v"))
123 dp.append(os.path.join(path,title+"_1.aac"))
124 dp.append(os.path.join(path,title+"_2.aac"))
125 dp.append(os.path.join(path,title+"_1.mp3"))
126 dp.append(os.path.join(path,title+"_2.mp3"))
127 dp.append(os.path.join(path,title+".srt"))
128 if os.path.exists(os.path.join(path,title+".ts"))and os.path.exists(os.path.join(path,title+".ts.b25")):
129 if os.path.getsize(os.path.join(path,title+".ts"))*10>os.path.getsize(os.path.join(path,title+".ts.b25")):
130 if os.path.getsize(os.path.join(path,title+".ts"))>1000*1000*100:
131 dp.append(os.path.join(path,title+".ts.b25"))