3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
25 Bitrate_LowHD = "2500"
27 Bitrate_Short = "1250"
28 #Bitrate_Tall = "2500"
29 #Bitrate_Grande = "3750"
30 #Bitrate_Venti = "5000"
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("\[二\]", pout):
66 elif re.search('(二)', pout):
68 elif re.search('\(二\)', pout):
72 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
76 elif chtxt == "hisch":
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 status.changeB25Decoding(-1)
94 def timetv2avi(pout, chtxt, btime, etime, opt):
95 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
96 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
97 extt = os.path.splitext(pout)
99 tnow = datetime.datetime.now()
103 tnow = datetime.datetime.now()
105 rectime = dt.seconds-10
106 rectime = str(rectime)
107 #recdblist.printutf8(tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime)
108 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
109 aviin = tsout + ".ts"
112 if re.search("5", opt):
114 if re.search("d", opt):
116 if re.search(u"\[二\]", pout):
118 elif re.search(u'(二)', pout):
120 elif re.search(u'\(二\)', pout):
124 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
128 elif chtxt == "hisch":
137 dualaudiots2avi(aviin, tsout + ".sa.avi")
138 aviin = tsout + ".sa.avi"
140 dualaudiots2avi(aviin, tsout + ".sa.avi")
141 aviin = tsout + ".sa.avi"
142 def ts2avi(pin, pout, opt):
143 status.changeEncoding(1)
144 #status.setEncoding(status.getEncoding() + 1)
146 ts2x264.ts2x264(pin, pout, opt)
149 status.changeEncoding(-1)
150 #status.setEncoding(status.getEncoding()-1)
151 def tv2avi(pout, chtxt, btime, etime, opt):
152 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
153 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
157 extt = os.path.splitext(pout)
159 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
160 aviin = tsout + ".ts"
163 if re.search("5", opt):
165 if re.search("d", opt):
167 if re.search(u'\[二\]', pout):
169 elif re.search(u'(二)', pout):
171 elif re.search(u'\(二\)', pout):
174 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
178 elif chtxt == "hisch":
185 dualaudiots2avi(aviin, tsout + ".sa.avi")
186 aviin = tsout + ".sa.avi"
188 dualaudiots2avi(aviin, tsout + ".sa.avi")
189 aviin = tsout + ".sa.avi"
190 ts2x264.ts2x264(aviin, pout, opts)
192 def b252avi(pout, chtxt, opt):
193 extt = os.path.splitext(pout)
195 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
196 aviin = tsout + ".ts"
199 if re.search("5", opt):
201 if re.search("d", opt):
203 if re.search(u'\[二\]', pout):
205 elif re.search(u'(二)', pout):
207 elif re.search(u'\(二\)', pout):
211 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
215 elif chtxt == "hisch":
224 dualaudiots2avi(aviin, tsout + ".sa.avi")
225 aviin = tsout + ".sa.avi"
227 dualaudiots2avi(aviin, tsout + ".sa.avi")
228 aviin = tsout + ".sa.avi"
229 ts2x264.ts2x264(aviin, pout, opts)
230 def dualaudiots2avi(pin, pout):
231 bontsdemux = configreader.getpath('bontsdemux')
232 bonpin = "Z:\\" + pin[1:]
233 outf = os.path.splitext(pin)[0]
234 bonpout = "Z:\\" + outf[1:]
235 xvfb = configreader.getpath('xvfb-run')
236 logpath=pin.replace("ts","log")
237 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
238 #recdblist.printutf8(exe)
239 exe = xvfb + ' -a ' + exe
240 recdblist.printutf8(exe)
242 ffpin1 = pin.replace("ts", "wav")
243 ffpin2 = pin.replace("ts", "m2v")
244 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
245 recdblist.printutf8(exe)
246 #commands.getoutput(exe)
250 def dualaudio2sep(pin, pout, delay):
254 bontsdemux = configreader.getpath('bontsdemux')
255 wine = configreader.getpath('wine')
256 xvfb = configreader.getpath('xvfb-run')
257 bonpin = "Z:\\" + pin[1:]
258 outf = os.path.splitext(pin)[0]
259 bonpout = "Z:\\" + outf[1:]
260 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
261 #recdblist.printutf8(exe)
262 exe = xvfb + ' -a ' + exe
263 recdblist.printutf8(exe)
264 commands.getoutput(exe.encode('utf-8'))
265 ffpin = pin.replace(".ts", "")
266 ffpin1 = pin.replace("ts", "wav")
267 ffpin2 = pin.replace("ts", "m2v")
268 ffpout1 = ffpin + "1_delay" + delay + ".wav"
269 ffpout2 = ffpin + "2_delay" + delay + ".wav"
270 ffpout3 = ffpin + "_delay" + delay + ".m2v"
271 shutil.move(ffpin1, ffpout1)
272 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
273 exe = xvfb + ' -a ' + exe
274 recdblist.printutf8(exe)
275 commands.getoutput(exe.encode('utf-8'))
277 shutil.move(ffpin1, ffpout2)
278 shutil.move(ffpin2, ffpout3)
279 #ffpout21=ffpout1.replace(".wav",".ogg")
280 #ffpout22=ffpout2.replace(".wav",".ogg")
281 #aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
282 #aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
283 aexe = "ffmpeg -i \"" + ffpout3 + "\" -i \"" + ffpout1 + "\" -i \"" + ffpout2 + "\" -r 29.97 -vsync 200 -vcodec copy -acodec copy -f avi " + pout + " -acodec copy -newaudio"
284 recdblist.printutf8(aexe)
287 commands.getoutput(aexe.encode('utf-8'))
288 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
289 #recdblist.printutf8(exe)
294 def pentaaudiots2avi(pin, pout):
295 bontsdemux = configreader.getpath('bontsdemux')
296 bonpin = "Z:\\" + pin[1:]
297 xvfb = configreader.getpath('xvfb-run')
298 outf = os.path.splitext(pin)[0]
299 bonpout = "Z:\\" + outf[1:]
300 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
301 #recdblist.printutf8(exe)
302 exe = xvfb + ' -a ' + exe
303 #exe = 'xvfb-run -a ' + exe
304 #exe='export Display=:2&&'+exe
305 recdblist.printutf8(exe)
306 commands.getoutput(exe.encode('utf-8'))
308 ffpin1 = pin.replace("ts", "wav")
309 ffpin2 = pin.replace("ts", "m2v")
310 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
311 recdblist.printutf8(exe)
312 commands.getoutput(exe.encode('utf-8'))