3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
26 def timetv2b25(pout, chtxt, btime, etime,opt):
30 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
31 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
32 extt = os.path.splitext(pout)
36 tnow = datetime.datetime.now()
40 tnow = datetime.datetime.now()
42 rectime = dt.seconds-10
43 rectime = str(rectime)
44 tv2ts.tv2b25ts(tsout+".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
45 def b252ts(pout,chtxt,btime,etime,opt):
47 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
49 status.setB25Decoding(status.getB25Decoding()+1)
51 tv2ts.b252ts(pout+".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
56 if re.search("5",opt):
58 if re.search("d",opt):
60 if re.search("\[二\]", pout):
62 elif re.search('(二)', pout):
64 elif re.search('\(二\)', pout):
68 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
72 elif chtxt == "hisch":
80 if re.search("x",opt):
85 dualaudiots2avi(aviin, tsout + "sa.avi")
86 aviin = tsout + "sa.avi"
88 dualaudiots2avi(aviin, tsout + "sa.avi")
89 aviin = tsout + "sa.avi"
92 status.setB25Decoding(status.getB25Decoding()-1)
93 def timetv2avi(pout, chtxt, btime, etime,opt):
94 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
95 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
96 extt = os.path.splitext(pout)
100 tnow = datetime.datetime.now()
104 tnow = datetime.datetime.now()
106 rectime = dt.seconds-10
107 rectime = str(rectime)
108 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
109 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
110 aviin = tsout + ".ts"
113 if re.search("5",opt):
115 if re.search("d",opt):
117 if re.search("\[二\]", pout):
119 elif re.search('(二)', pout):
121 elif re.search('\(二\)', pout):
125 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
129 elif chtxt == "hisch":
137 if re.search("x",opt):
142 dualaudiots2avi(aviin, tsout + "sa.avi")
143 aviin = tsout + "sa.avi"
145 dualaudiots2avi(aviin, tsout + "sa.avi")
146 aviin = tsout + "sa.avi"
147 bt=datetime.datetime.now()+datetime.timedelta(seconds=600)
148 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
149 et=datetime.datetime.now()+datetime.timedelta(seconds=600)
150 etime=et.strftime("%Y-%m-%d %H:%M:%S")
151 title=os.path.split(tsout)[1]
156 def ts2avi(pin,pout,opt):
157 status.setEncoding(status.getEncoding()+1)
158 if re.search("x",opt):
160 ts2xvid.ts2xvid(pin, pout, opt)
165 ts2x264.ts2x264(pin, pout, opt)
168 status.setEncoding(status.getEncoding()-1)
169 def tv2avi(pout, chtxt, btime, etime,opt):
170 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
171 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
175 extt = os.path.splitext(pout)
177 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
178 aviin = tsout + ".ts"
181 if re.search("5",opt):
183 if re.search("d",opt):
185 if re.search('\[二\]', pout):
187 elif re.search('(二)', pout):
189 elif re.search('\(二\)', pout):
192 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
196 elif chtxt == "hisch":
203 dualaudiots2avi(aviin, tsout + "sa.avi")
204 aviin = tsout + "sa.avi"
206 dualaudiots2avi(aviin, tsout + "sa.avi")
207 aviin = tsout + "sa.avi"
208 ts2x264.ts2x264(aviin, pout,opts)
210 def b252avi(pout, chtxt,opt):
211 extt = os.path.splitext(pout)
213 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
214 aviin = tsout + ".ts"
217 if re.search("5",opt):
219 if re.search("d",opt):
221 if re.search('\[二\]', pout):
223 elif re.search('(二)', pout):
225 elif re.search('\(二\)', pout):
229 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
233 elif chtxt == "hisch":
241 if re.search("x",opt):
246 dualaudiots2avi(aviin, tsout + "sa.avi")
247 aviin = tsout + "sa.avi"
249 dualaudiots2avi(aviin, tsout + "sa.avi")
250 aviin = tsout + "sa.avi"
252 ts2xvid.ts2xvid(aviin, pout,opts)
254 ts2x264.ts2x264(aviin, pout,opts)
260 def dualaudiots2avi(pin, pout):
261 bontsdemux = configreader.getpath('bontsdemux')
262 wine = configreader.getpath('wine')
263 bonpin = "Z:\\" + pin[1:]
264 outf = os.path.splitext(pin)[0]
265 bonpout = "Z:\\" + outf[1:]
266 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
268 exe = 'xvfb-run -a ' + exe
269 #exe='export Display=:2&&'+exe
272 ffpin1 = pin.replace("ts", "wav")
273 ffpin2 = pin.replace("ts", "m2v")
274 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
279 def dualaudio2sep(pin,pout,delay):
280 bontsdemux = configreader.getpath('bontsdemux')
281 wine = configreader.getpath('wine')
282 bonpin = "Z:\\" + pin[1:]
283 outf = os.path.splitext(pin)[0]
284 bonpout = "Z:\\" + outf[1:]
285 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
287 exe = 'xvfb-run -a ' + exe
288 #exe='export Display=:2&&'+exe
291 ffpin=pin.replace(".ts","")
292 ffpin1 = pin.replace("ts", "wav")
293 ffpin2 = pin.replace("ts", "m2v")
294 ffpout1=ffpin+"1_delay"+delay+".wav"
295 ffpout2=ffpin+"2_delay"+delay+".wav"
296 shutil.move(ffpin1, ffpout1)
297 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
298 exe = 'xvfb-run -a ' + exe
300 shutil.move(ffpin1, ffpout2)
301 ffpout21=ffpout1.replace(".wav",".ogg")
302 ffpout22=ffpout2.replace(".wav",".ogg")
303 aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
304 aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
308 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
314 def pentaaudiots2avi(pin, pout):
315 bontsdemux = configreader.getpath('bontsdemux')
316 wine = configreader.getpath('wine')
317 bonpin = "Z:\\" + pin[1:]
318 outf = os.path.splitext(pin)[0]
319 bonpout = "Z:\\" + outf[1:]
320 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
322 exe = 'xvfb-run -a ' + exe
323 #exe='export Display=:2&&'+exe
326 ffpin1 = pin.replace("ts", "wav")
327 ffpin2 = pin.replace("ts", "m2v")
328 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"