3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
25 def timetv2b25(pout, chtxt, btime, etime,opt):
29 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
30 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
31 extt = os.path.splitext(pout)
33 tnow = datetime.datetime.now()
37 tnow = datetime.datetime.now()
39 rectime = dt.seconds-10
40 rectime = str(rectime)
41 tv2ts.tv2b25ts(tsout+".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
42 def b252ts(pout,chtxt,btime,etime,opt):
44 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
46 status.setB25Decoding(status.getB25Decoding()+1)
48 tv2ts.b252ts(pout+".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
53 if re.search("5",opt):
55 if re.search("d",opt):
57 if re.search("\[二\]", pout):
59 elif re.search('(二)', pout):
61 elif re.search('\(二\)', pout):
65 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
69 elif chtxt == "hisch":
78 dualaudiots2avi(aviin, tsout + "sa.avi")
79 aviin = tsout + "sa.avi"
81 dualaudiots2avi(aviin, tsout + "sa.avi")
82 aviin = tsout + "sa.avi"
85 status.setB25Decoding(status.getB25Decoding()-1)
86 def timetv2avi(pout, chtxt, btime, etime,opt):
87 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
88 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
89 extt = os.path.splitext(pout)
91 tnow = datetime.datetime.now()
95 tnow = datetime.datetime.now()
97 rectime = dt.seconds-10
98 rectime = str(rectime)
99 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
100 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
101 aviin = tsout + ".ts"
104 if re.search("5",opt):
106 if re.search("d",opt):
108 if re.search("\[二\]", pout):
110 elif re.search('(二)', pout):
112 elif re.search('\(二\)', pout):
116 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
120 elif chtxt == "hisch":
129 dualaudiots2avi(aviin, tsout + "sa.avi")
130 aviin = tsout + "sa.avi"
132 dualaudiots2avi(aviin, tsout + "sa.avi")
133 aviin = tsout + "sa.avi"
134 def ts2avi(pin,pout,opt):
135 status.setEncoding(status.getEncoding()+1)
136 if re.search("x",opt):
138 ts2xvid.ts2xvid(pin, pout, opt)
143 ts2x264.ts2x264(pin, pout, opt)
146 status.setEncoding(status.getEncoding()-1)
147 def tv2avi(pout, chtxt, btime, etime,opt):
148 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
149 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
153 extt = os.path.splitext(pout)
155 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
156 aviin = tsout + ".ts"
159 if re.search("5",opt):
161 if re.search("d",opt):
163 if re.search('\[二\]', pout):
165 elif re.search('(二)', pout):
167 elif re.search('\(二\)', pout):
170 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
174 elif chtxt == "hisch":
181 dualaudiots2avi(aviin, tsout + "sa.avi")
182 aviin = tsout + "sa.avi"
184 dualaudiots2avi(aviin, tsout + "sa.avi")
185 aviin = tsout + "sa.avi"
186 ts2x264.ts2x264(aviin, pout,opts)
188 def b252avi(pout, chtxt,opt):
189 extt = os.path.splitext(pout)
191 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
192 aviin = tsout + ".ts"
195 if re.search("5",opt):
197 if re.search("d",opt):
199 if re.search('\[二\]', pout):
201 elif re.search('(二)', pout):
203 elif re.search('\(二\)', pout):
207 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
211 elif chtxt == "hisch":
219 if re.search("x",opt):
224 dualaudiots2avi(aviin, tsout + "sa.avi")
225 aviin = tsout + "sa.avi"
227 dualaudiots2avi(aviin, tsout + "sa.avi")
228 aviin = tsout + "sa.avi"
230 ts2xvid.ts2xvid(aviin, pout,opts)
232 ts2x264.ts2x264(aviin, pout,opts)
233 def dualaudiots2avi(pin, pout):
234 bontsdemux = configreader.getpath('bontsdemux')
235 bonpin = "Z:\\" + pin[1:]
236 outf = os.path.splitext(pin)[0]
237 bonpout = "Z:\\" + outf[1:]
238 xvfb = configreader.getpath('xvfb-run')
239 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
241 exe = xvfb+' -a ' + exe
244 ffpin1 = pin.replace("ts", "wav")
245 ffpin2 = pin.replace("ts", "m2v")
246 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
248 #commands.getoutput(exe)
252 def dualaudio2sep(pin,pout,delay):
256 bontsdemux = configreader.getpath('bontsdemux')
257 wine = configreader.getpath('wine')
258 xvfb = configreader.getpath('xvfb-run')
259 bonpin = "Z:\\" + pin[1:]
260 outf = os.path.splitext(pin)[0]
261 bonpout = "Z:\\" + outf[1:]
262 exe = wine+' ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
264 exe = xvfb+' -a ' + exe
266 commands.getoutput(exe)
267 ffpin=pin.replace(".ts","")
268 ffpin1 = pin.replace("ts", "wav")
269 ffpin2 = pin.replace("ts", "m2v")
270 ffpout1=ffpin+"1_delay"+delay+".wav"
271 ffpout2=ffpin+"2_delay"+delay+".wav"
272 ffpout3=ffpin+"_delay"+delay+".m2v"
273 shutil.move(ffpin1, ffpout1)
274 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
275 exe = xvfb+' -a ' + exe
277 commands.getoutput(exe)
279 shutil.move(ffpin1, ffpout2)
280 shutil.move(ffpin2, ffpout3)
281 #ffpout21=ffpout1.replace(".wav",".ogg")
282 #ffpout22=ffpout2.replace(".wav",".ogg")
283 #aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
284 #aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
285 aexe="ffmpeg -i \""+ffpout3+"\" -i \""+ffpout1+"\" -i \""+ffpout2+"\" -r 29.97 -vsync 200 -vcodec copy -acodec copy -f avi "+pout+" -acodec copy -newaudio"
289 commands.getoutput(aexe)
290 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
296 def pentaaudiots2avi(pin, pout):
297 bontsdemux = configreader.getpath('bontsdemux')
298 bonpin = "Z:\\" + pin[1:]
299 xvfb = configreader.getpath('xvfb-run')
300 outf = os.path.splitext(pin)[0]
301 bonpout = "Z:\\" + outf[1:]
302 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
304 exe = xvfb+' -a ' + exe
305 #exe = 'xvfb-run -a ' + exe
306 #exe='export Display=:2&&'+exe
308 commands.getoutput(exe)
310 ffpin1 = pin.replace("ts", "wav")
311 ffpin2 = pin.replace("ts", "m2v")
312 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
314 commands.getoutput(exe)