3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
33 #Bitrate_Grande = 3750
35 def timetv2b25(pout, chtxt, btime, etime, opt):
39 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
40 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
41 extt = os.path.splitext(pout)
43 tnow = datetime.datetime.now()
47 tnow = datetime.datetime.now()
49 rectime = dt.seconds-10
50 rectime = str(rectime)
51 tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
52 def b252ts(pout, chtxt, btime, etime, opt):
54 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
56 #status.setB25Decoding(status.getB25Decoding() + 1)
57 status.changeB25Decoding(1)
59 tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
64 if re.search("5", opt):
66 if re.search("d", opt):
68 if re.search(u"\[二\]", pout):
70 elif re.search(u'(二)', pout):
72 elif re.search(u'\(二\)', pout):
75 dualaudio2sep(aviin,"167")
77 pentaaudiots2avi(aviin, tsout + ".sa.avi")
78 except Exception, inst:
79 print "Error happend in b252ts in tv2avi"
82 status.changeB25Decoding(-1)
83 """def timetv2avi(pout, chtxt, btime, etime, opt):
84 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
85 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
86 extt = os.path.splitext(pout)
88 tnow = datetime.datetime.now()
92 tnow = datetime.datetime.now()
94 rectime = dt.seconds-10
95 rectime = str(rectime)
96 #recdblist.printutf8(tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime)
97 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
101 if re.search("5", opt):
103 if re.search("d", opt):
105 if re.search(u"\[二\]", pout):
107 elif re.search(u'(二)', pout):
109 elif re.search(u'\(二\)', pout):
113 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
117 elif chtxt == "hisch":
126 dualaudiots2avi(aviin, tsout + ".sa.avi")
127 aviin = tsout + ".sa.avi"
129 dualaudiots2avi(aviin, tsout + ".sa.avi")
130 aviin = tsout + ".sa.avi"
132 def ts2avi(pin, pout, opt):
133 status.changeEncoding(1)
135 ts2x264.ts2x264(pin, pout, opt)
136 except Exception, inst:
137 print "error occures in tv2avi.py tv2avi"
140 status.changeEncoding(-1)
141 """def tv2avi(pout, chtxt, btime, etime, opt):
142 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
143 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
147 extt = os.path.splitext(pout)
149 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
150 aviin = tsout + ".ts"
153 if re.search("5", opt):
155 if re.search("d", opt):
157 if re.search(u'\[二\]', pout):
159 elif re.search(u'(二)', pout):
161 elif re.search(u'\(二\)', pout):
164 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
168 elif chtxt == "hisch":
175 dualaudiots2avi(aviin, tsout + ".sa.avi")
176 aviin = tsout + ".sa.avi"
178 dualaudiots2avi(aviin, tsout + ".sa.avi")
179 aviin = tsout + ".sa.avi"
180 ts2x264.ts2x264(aviin, pout, opts)
183 """def b252avi(pout, chtxt, opt):
184 extt = os.path.splitext(pout)
186 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
187 aviin = tsout + ".ts"
190 if re.search("5", opt):
192 if re.search("d", opt):
194 if re.search(u'\[二\]', pout):
196 elif re.search(u'(二)', pout):
198 elif re.search(u'\(二\)', pout):
202 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
206 elif chtxt == "hisch":
215 dualaudiots2avi(aviin, tsout + ".sa.avi")
216 aviin = tsout + ".sa.avi"
218 dualaudiots2avi(aviin, tsout + ".sa.avi")
219 aviin = tsout + ".sa.avi"
220 ts2x264.ts2x264(aviin, pout, opts)"""
221 def dualaudiots2avi(pin, pout):
222 bontsdemux = configreader.getpath('bontsdemux')
223 bonpin = "Z:\\" + pin[1:]
224 outf = os.path.splitext(pin)[0]
225 bonpout = "Z:\\" + outf[1:]
226 xvfb = configreader.getpath('xvfb-run')
227 logpath=pin.replace("ts","log")
228 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
229 #recdblist.printutf8(exe)
230 exe = xvfb + ' -a ' + exe
231 recdblist.printutf8(exe)
232 os.system(exe.encode('utf-8'))
233 ffpin1 = pin.replace("ts", "wav")
234 ffpin2 = pin.replace("ts", "m2v")
235 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
236 recdblist.printutf8(exe)
237 #commands.getoutput(exe)
238 os.system(exe.encode('utf-8'))
241 def dualaudio2sep(pin, delay):
245 bontsdemux = configreader.getpath('bontsdemux')
246 wine = configreader.getpath('wine')
247 xvfb = configreader.getpath('xvfb-run')
248 bonpin = "Z:\\" + pin[1:]
249 outf = os.path.splitext(pin)[0]
250 bonpout = "Z:\\" + outf[1:]
251 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
252 exe = xvfb + ' -a ' + exe
253 recdblist.printutf8(exe)
254 commands.getoutput(exe.encode('utf-8'))
255 ffpin = pin.replace(".ts", "")
256 ffpin1 = pin.replace("ts", "wav")
257 ffpin2 = pin.replace("ts", "m2v")
258 ffpout1 = ffpin + "_1.wav"
259 ffpout2 = ffpin + "_2.wav"
260 ffpout3 = ffpin + ".m2v"
261 shutil.move(ffpin1, ffpout1)
262 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
263 exe = xvfb + ' -a ' + exe
264 recdblist.printutf8(exe)
265 commands.getoutput(exe.encode('utf-8'))
267 shutil.move(ffpin1, ffpout2)
268 shutil.move(ffpin2, ffpout3)
269 ffpout21=ffpout1.replace(".wav",".mp3")
270 ffpout22=ffpout2.replace(".wav",".mp3")
271 if os.path.exists(configreader.getpath("NeroAAC")):
272 ffpout21=ffpout1.replace(".wav",".aac")
273 ffpout22=ffpout2.replace(".wav",".aac")
274 tv2audio.wav2aac_nero(ffpout1, ffpout21)
275 tv2audio.wav2aac_nero(ffpout2, ffpout22)
277 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
278 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
283 def pentaaudiots2avi(pin, pout):
284 bontsdemux = configreader.getpath('bontsdemux')
285 bonpin = "Z:\\" + pin[1:]
286 xvfb = configreader.getpath('xvfb-run')
287 outf = os.path.splitext(pin)[0]
288 bonpout = "Z:\\" + outf[1:]
289 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
290 exe = xvfb + ' -a ' + exe
291 recdblist.printutf8(exe)
292 commands.getoutput(exe.encode('utf-8'))
293 ffpin1 = pin.replace("ts", "wav")
294 ffpin2 = pin.replace("ts", "m2v")
295 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
296 recdblist.printutf8(exe)
297 commands.getoutput(exe.encode('utf-8'))