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 #print 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("\[二\]", pout):
118 elif re.search('(二)', pout):
120 elif re.search('\(二\)', 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)
145 if re.search("x", opt):
147 ts2xvid.ts2xvid(pin, pout, opt)
152 ts2x264.ts2x264(pin, pout, opt)
155 status.changeEncoding(-1)
156 #status.setEncoding(status.getEncoding()-1)
157 def tv2avi(pout, chtxt, btime, etime, opt):
158 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
159 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
163 extt = os.path.splitext(pout)
165 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
166 aviin = tsout + ".ts"
169 if re.search("5", opt):
171 if re.search("d", opt):
173 if re.search('\[二\]', pout):
175 elif re.search('(二)', pout):
177 elif re.search('\(二\)', pout):
180 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
184 elif chtxt == "hisch":
191 dualaudiots2avi(aviin, tsout + ".sa.avi")
192 aviin = tsout + ".sa.avi"
194 dualaudiots2avi(aviin, tsout + ".sa.avi")
195 aviin = tsout + ".sa.avi"
196 ts2x264.ts2x264(aviin, pout, opts)
198 def b252avi(pout, chtxt, opt):
199 extt = os.path.splitext(pout)
201 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
202 aviin = tsout + ".ts"
205 if re.search("5", opt):
207 if re.search("d", opt):
209 if re.search('\[二\]', pout):
211 elif re.search('(二)', pout):
213 elif re.search('\(二\)', pout):
217 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
221 elif chtxt == "hisch":
229 if re.search("x", opt):
234 dualaudiots2avi(aviin, tsout + ".sa.avi")
235 aviin = tsout + ".sa.avi"
237 dualaudiots2avi(aviin, tsout + ".sa.avi")
238 aviin = tsout + ".sa.avi"
240 ts2xvid.ts2xvid(aviin, pout, opts)
242 ts2x264.ts2x264(aviin, pout, opts)
243 def dualaudiots2avi(pin, pout):
244 bontsdemux = configreader.getpath('bontsdemux')
245 bonpin = "Z:\\" + pin[1:]
246 outf = os.path.splitext(pin)[0]
247 bonpout = "Z:\\" + outf[1:]
248 xvfb = configreader.getpath('xvfb-run')
249 logpath=pin.replace("ts","log")
250 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
252 exe = xvfb + ' -a ' + exe
255 ffpin1 = pin.replace("ts", "wav")
256 ffpin2 = pin.replace("ts", "m2v")
257 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
259 #commands.getoutput(exe)
263 def dualaudio2sep(pin, pout, delay):
267 bontsdemux = configreader.getpath('bontsdemux')
268 wine = configreader.getpath('wine')
269 xvfb = configreader.getpath('xvfb-run')
270 bonpin = "Z:\\" + pin[1:]
271 outf = os.path.splitext(pin)[0]
272 bonpout = "Z:\\" + outf[1:]
273 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
275 exe = xvfb + ' -a ' + exe
277 commands.getoutput(exe)
278 ffpin = pin.replace(".ts", "")
279 ffpin1 = pin.replace("ts", "wav")
280 ffpin2 = pin.replace("ts", "m2v")
281 ffpout1 = ffpin + "1_delay" + delay + ".wav"
282 ffpout2 = ffpin + "2_delay" + delay + ".wav"
283 ffpout3 = ffpin + "_delay" + delay + ".m2v"
284 shutil.move(ffpin1, ffpout1)
285 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
286 exe = xvfb + ' -a ' + exe
288 commands.getoutput(exe)
290 shutil.move(ffpin1, ffpout2)
291 shutil.move(ffpin2, ffpout3)
292 #ffpout21=ffpout1.replace(".wav",".ogg")
293 #ffpout22=ffpout2.replace(".wav",".ogg")
294 #aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
295 #aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
296 aexe = "ffmpeg -i \"" + ffpout3 + "\" -i \"" + ffpout1 + "\" -i \"" + ffpout2 + "\" -r 29.97 -vsync 200 -vcodec copy -acodec copy -f avi " + pout + " -acodec copy -newaudio"
300 commands.getoutput(aexe)
301 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
307 def pentaaudiots2avi(pin, pout):
308 bontsdemux = configreader.getpath('bontsdemux')
309 bonpin = "Z:\\" + pin[1:]
310 xvfb = configreader.getpath('xvfb-run')
311 outf = os.path.splitext(pin)[0]
312 bonpout = "Z:\\" + outf[1:]
313 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
315 exe = xvfb + ' -a ' + exe
316 #exe = 'xvfb-run -a ' + exe
317 #exe='export Display=:2&&'+exe
319 commands.getoutput(exe)
321 ffpin1 = pin.replace("ts", "wav")
322 ffpin2 = pin.replace("ts", "m2v")
323 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
325 commands.getoutput(exe)