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]
19 """tpavi=os.path.join(dir,title+".avi")
20 tpmkv=os.path.join(dir, title+".mkv")
21 tv2avi.ts2avi(pin, tpavi, opt)
23 avi2mkv(tpavi,tpmkv,opt)"""
24 tpraw=os.path.join(dir, title+".264")
25 tpmkv=os.path.join(dir, title+".mkv")
26 tv2avi.ts2raw(pin, tpraw, opt)
28 raw2mkv(tpraw, tpmkv, opt)
29 def raw2mkv(pin,pout,opt):#x264
30 dir=os.path.split(pout)[0]
31 title=os.path.split(pout)[1]
32 title=os.path.splitext(title)[0]
33 duration="--default-duration 0:30000/1001fps "
36 if re.search("a",opt):
37 duration="--default-duration 0:24000/1001fps "
38 elif re.search("v",opt):
39 duration="--default-duration 0:24000/1001fps "
40 if re.search("d",opt):
42 duration="--default-duration 0:30000/1001fps "##ffmpegが24fpsに対応していないための措置
43 elif re.search("5",opt):
45 duration="--default-duration 0:30000/1001fps "##ffmpegが24fpsに対応していないための措置
46 exe = configreader.getpath("mkvmerge")
48 os.environ['LANG']="ja_JP.UTF-8"
50 wineexe=configreader.getpath("wine")
51 pincap=pin.replace(".264",".srt")
52 cap2ass=configreader.getpath("Caption2Ass")
53 pints=pin.replace(".264",".ts")
54 paac1=pin.replace(".264","_1.aac")
55 paac2=pin.replace(".264","_2.aac")
56 recdblist.printutf8(paac1)
57 if not os.path.exists(paac1):
58 paac1=pin.replace(".264","_1.mp3")
59 if not os.path.exists(paac2):
60 paac2=pin.replace(".264","_2.mp3")
61 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
62 e1=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 "+duration+u"--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"
63 e1s=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 "+duration+u"--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"
64 if os.path.isfile(cap2ass):
66 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
71 wineexe=configreader.getpath("wine")
72 pincap=pin.replace(".264",".srt")
73 cap2ass=configreader.getpath("Caption2Ass")
74 pints=pin.replace(".264",".ts")
75 paac1=pin.replace(".264","_1.aac")
76 paac2=pin.replace(".264","_2.aac")
77 recdblist.printutf8(paac1)
78 if not os.path.exists(paac1):
79 paac1=pin.replace(".264","_1.mp3")
80 if not os.path.exists(paac2):
81 paac2=pin.replace(".264","_2.mp3")
82 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
83 e1=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 "+duration+u"--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"
84 e1s=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 "+duration+u"--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"
85 if os.path.isfile(cap2ass):
87 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
92 wineexe=configreader.getpath("wine")
93 pincap=pin.replace(".264",".srt")
94 cap2ass=configreader.getpath("Caption2Ass")
95 pints=pin.replace(".264",".ts")
96 pinaac=pin.replace(".264",".aac")
97 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
98 e1="ffmpeg -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\""
99 e2=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 "+duration+u"--forced-track 0:no -a 0 -D -S \""+pinaac+"\" --track-order 0:0,1:0"
100 e2s=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 "+duration+u"--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"
101 if os.path.isfile(cap2ass):
104 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
105 txt=txt+execcomd(e2s)
108 recdblist.addlog(pout, txt, "mkvmerge-log")
109 logo=pout.replace(".mkv",".log")
110 if status.getSettings_auto_del_tmp()==1:
111 if os.path.exists(pout):
112 if os.path.getsize(pout)>100*1000*1000:
114 def avi2mkv(pin,pout,opt):
115 dir=os.path.split(pout)[0]
116 title=os.path.split(pout)[1]
117 title=os.path.splitext(title)[0]
120 if re.search("d",opt):
122 elif re.search("5",opt):
124 exe = configreader.getpath("mkvmerge")
126 os.environ['LANG']="ja_JP.UTF-8"
128 wineexe=configreader.getpath("wine")
129 pincap=pin.replace(".avi",".srt")
130 cap2ass=configreader.getpath("Caption2Ass")
131 pints=pin.replace(".avi",".ts")
132 paac1=pin.replace(".avi","_1.aac")
133 paac2=pin.replace(".avi","_2.aac")
134 recdblist.printutf8(paac1)
135 if not os.path.exists(paac1):
136 paac1=pin.replace(".avi","_1.mp3")
137 if not os.path.exists(paac2):
138 paac2=pin.replace(".avi","_2.mp3")
139 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
140 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"
141 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"
142 if os.path.isfile(cap2ass):
144 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
145 txt=txt+execcomd(e1s)
148 elif ispentaaudio==1:
149 wineexe=configreader.getpath("wine")
150 pincap=pin.replace(".avi",".srt")
151 cap2ass=configreader.getpath("Caption2Ass")
152 pints=pin.replace(".avi",".ts")
153 paac1=pin.replace(".avi","_1.aac")
154 paac2=pin.replace(".avi","_2.aac")
155 recdblist.printutf8(paac1)
156 if not os.path.exists(paac1):
157 paac1=pin.replace(".avi","_1.mp3")
158 if not os.path.exists(paac2):
159 paac2=pin.replace(".avi","_2.mp3")
160 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
161 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"
162 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"
163 if os.path.isfile(cap2ass):
165 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
166 txt=txt+execcomd(e1s)
170 wineexe=configreader.getpath("wine")
171 pincap=pin.replace(".avi",".srt")
172 cap2ass=configreader.getpath("Caption2Ass")
173 pints=pin.replace(".avi",".ts")
174 pinaac=pin.replace(".avi",".aac")
175 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
176 e1="ffmpeg -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\""
177 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"
178 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"
179 if os.path.isfile(cap2ass):
182 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
183 txt=txt+execcomd(e2s)
186 recdblist.addlog(pout, txt, "mkvmerge-log")
187 logo=pout.replace(".mkv",".log")
188 if status.getSettings_auto_del_tmp()==1:
189 if os.path.exists(pout):
190 if os.path.getsize(pout)>100*1000*1000:
194 cmdt=u"nice -n 17 "+cmd
196 txt=u"Cmd : "+cmd+"\n"
197 txt2=commands.getoutput(cmdt.encode('utf-8'))
198 txt=txt+unicode(txt2,"utf-8")+"\n"
202 def deltitle(path,title):
204 dp.append(os.path.join(path,title+".avi"))
205 dp.append(os.path.join(path,title+".120.avi"))
206 dp.append(os.path.join(path,title+".noodml.avi"))
207 dp.append(os.path.join(path,title+".aac"))
208 dp.append(os.path.join(path,title+".m2v"))
209 dp.append(os.path.join(path,title+"_1.aac"))
210 dp.append(os.path.join(path,title+"_2.aac"))
211 dp.append(os.path.join(path,title+"_1.mp3"))
212 dp.append(os.path.join(path,title+"_2.mp3"))
213 dp.append(os.path.join(path,title+".srt"))
214 if os.path.exists(os.path.join(path,title+".ts"))and os.path.exists(os.path.join(path,title+".ts.b25")):
215 if os.path.getsize(os.path.join(path,title+".ts"))*10>os.path.getsize(os.path.join(path,title+".ts.b25")):
216 if os.path.getsize(os.path.join(path,title+".ts"))>1000*1000*100:
217 dp.append(os.path.join(path,title+".ts.b25"))
218 if os.path.exists(os.path.join(path,title+".mkv")):
219 if os.path.getsize(os.path.join(path,title+".mkv"))>1000*1000*10: