3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
29 #Bitrate_Grande = 3750
31 def timetv2b25(pout, chtxt, btime, etime, opt):
35 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
36 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
37 extt = os.path.splitext(pout)
39 tnow = datetime.datetime.now()
43 tnow = datetime.datetime.now()
45 rectime = dt.seconds-10
46 rectime = str(rectime)
47 tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
48 def b252ts(pout, chtxt, btime, etime, opt):
50 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
52 #status.setB25Decoding(status.getB25Decoding() + 1)
53 status.changeB25Decoding(1)
55 tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
60 if re.search("5", opt):
62 if re.search("d", opt):
64 if re.search(u"\[二\]", pout):
66 elif re.search(u'(二)', pout):
68 elif re.search(u'\(二\)', pout):
71 dualaudiots2avi(aviin, tsout + ".sa.avi")
73 dualaudiots2avi(aviin, tsout + ".sa.avi")
74 except Exception, inst:
75 print "Error happend in b252ts in tv2avi"
78 status.changeB25Decoding(-1)
79 def timetv2avi(pout, chtxt, btime, etime, opt):
80 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
81 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
82 extt = os.path.splitext(pout)
84 tnow = datetime.datetime.now()
88 tnow = datetime.datetime.now()
90 rectime = dt.seconds-10
91 rectime = str(rectime)
92 #recdblist.printutf8(tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime)
93 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
97 if re.search("5", opt):
99 if re.search("d", opt):
101 if re.search(u"\[二\]", pout):
103 elif re.search(u'(二)', pout):
105 elif re.search(u'\(二\)', pout):
109 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
113 elif chtxt == "hisch":
122 dualaudiots2avi(aviin, tsout + ".sa.avi")
123 aviin = tsout + ".sa.avi"
125 dualaudiots2avi(aviin, tsout + ".sa.avi")
126 aviin = tsout + ".sa.avi"
127 def ts2avi(pin, pout, opt):
128 status.changeEncoding(1)
129 #status.setEncoding(status.getEncoding() + 1)
131 ts2x264.ts2x264(pin, pout, opt)
132 except Exception, inst:
133 print "error occures in tv2avi.py tv2avi"
136 status.changeEncoding(-1)
137 #status.setEncoding(status.getEncoding()-1)
138 def tv2avi(pout, chtxt, btime, etime, opt):
139 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
140 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
144 extt = os.path.splitext(pout)
146 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
147 aviin = tsout + ".ts"
150 if re.search("5", opt):
152 if re.search("d", opt):
154 if re.search(u'\[二\]', pout):
156 elif re.search(u'(二)', pout):
158 elif re.search(u'\(二\)', pout):
161 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
165 elif chtxt == "hisch":
172 dualaudiots2avi(aviin, tsout + ".sa.avi")
173 aviin = tsout + ".sa.avi"
175 dualaudiots2avi(aviin, tsout + ".sa.avi")
176 aviin = tsout + ".sa.avi"
177 ts2x264.ts2x264(aviin, pout, opts)
179 def b252avi(pout, chtxt, opt):
180 extt = os.path.splitext(pout)
182 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
183 aviin = tsout + ".ts"
186 if re.search("5", opt):
188 if re.search("d", opt):
190 if re.search(u'\[二\]', pout):
192 elif re.search(u'(二)', pout):
194 elif re.search(u'\(二\)', pout):
198 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
202 elif chtxt == "hisch":
211 dualaudiots2avi(aviin, tsout + ".sa.avi")
212 aviin = tsout + ".sa.avi"
214 dualaudiots2avi(aviin, tsout + ".sa.avi")
215 aviin = tsout + ".sa.avi"
216 ts2x264.ts2x264(aviin, pout, opts)
217 def dualaudiots2avi(pin, pout):
218 bontsdemux = configreader.getpath('bontsdemux')
219 bonpin = "Z:\\" + pin[1:]
220 outf = os.path.splitext(pin)[0]
221 bonpout = "Z:\\" + outf[1:]
222 xvfb = configreader.getpath('xvfb-run')
223 logpath=pin.replace("ts","log")
224 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
225 #recdblist.printutf8(exe)
226 exe = xvfb + ' -a ' + exe
227 recdblist.printutf8(exe)
228 os.system(exe.encode('utf-8'))
229 ffpin1 = pin.replace("ts", "wav")
230 ffpin2 = pin.replace("ts", "m2v")
231 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
232 recdblist.printutf8(exe)
233 #commands.getoutput(exe)
234 os.system(exe.encode('utf-8'))
237 def dualaudio2sep(pin, pout, delay):
241 bontsdemux = configreader.getpath('bontsdemux')
242 wine = configreader.getpath('wine')
243 xvfb = configreader.getpath('xvfb-run')
244 bonpin = "Z:\\" + pin[1:]
245 outf = os.path.splitext(pin)[0]
246 bonpout = "Z:\\" + outf[1:]
247 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
248 #recdblist.printutf8(exe)
249 exe = xvfb + ' -a ' + exe
250 recdblist.printutf8(exe)
251 commands.getoutput(exe.encode('utf-8'))
252 ffpin = pin.replace(".ts", "")
253 ffpin1 = pin.replace("ts", "wav")
254 ffpin2 = pin.replace("ts", "m2v")
255 ffpout1 = ffpin + "1_delay" + delay + ".wav"
256 ffpout2 = ffpin + "2_delay" + delay + ".wav"
257 ffpout3 = ffpin + "_delay" + delay + ".m2v"
258 shutil.move(ffpin1, ffpout1)
259 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
260 exe = xvfb + ' -a ' + exe
261 recdblist.printutf8(exe)
262 commands.getoutput(exe.encode('utf-8'))
264 shutil.move(ffpin1, ffpout2)
265 shutil.move(ffpin2, ffpout3)
266 #ffpout21=ffpout1.replace(".wav",".ogg")
267 #ffpout22=ffpout2.replace(".wav",".ogg")
268 #aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
269 #aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
270 aexe = "ffmpeg -i \"" + ffpout3 + "\" -i \"" + ffpout1 + "\" -i \"" + ffpout2 + "\" -r 29.97 -vsync 200 -vcodec copy -acodec copy -f avi " + pout + " -acodec copy -newaudio"
271 recdblist.printutf8(aexe)
274 commands.getoutput(aexe.encode('utf-8'))
275 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
276 #recdblist.printutf8(exe)
281 def pentaaudiots2avi(pin, pout):
282 bontsdemux = configreader.getpath('bontsdemux')
283 bonpin = "Z:\\" + pin[1:]
284 xvfb = configreader.getpath('xvfb-run')
285 outf = os.path.splitext(pin)[0]
286 bonpout = "Z:\\" + outf[1:]
287 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
288 #recdblist.printutf8(exe)
289 exe = xvfb + ' -a ' + exe
290 #exe = 'xvfb-run -a ' + exe
291 #exe='export Display=:2&&'+exe
292 recdblist.printutf8(exe)
293 commands.getoutput(exe.encode('utf-8'))
295 ffpin1 = pin.replace("ts", "wav")
296 ffpin2 = pin.replace("ts", "m2v")
297 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
298 recdblist.printutf8(exe)
299 commands.getoutput(exe.encode('utf-8'))