3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
26 def timetv2b25(pout, chtxt, btime, etime,opt):
30 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
31 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
32 extt = os.path.splitext(pout)
34 tnow = datetime.datetime.now()
38 tnow = datetime.datetime.now()
40 rectime = dt.seconds-10
41 rectime = str(rectime)
42 tv2ts.tv2b25ts(tsout+".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
43 def b252ts(pout,chtxt,btime,etime,opt):
45 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
47 status.setB25Decoding(status.getB25Decoding()+1)
49 tv2ts.b252ts(pout+".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
54 if re.search("5",opt):
56 if re.search("d",opt):
58 if re.search("\[二\]", pout):
60 elif re.search('(二)', pout):
62 elif re.search('\(二\)', pout):
66 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
70 elif chtxt == "hisch":
79 dualaudiots2avi(aviin, tsout + "sa.avi")
80 aviin = tsout + "sa.avi"
82 dualaudiots2avi(aviin, tsout + "sa.avi")
83 aviin = tsout + "sa.avi"
86 status.setB25Decoding(status.getB25Decoding()-1)
87 def timetv2avi(pout, chtxt, btime, etime,opt):
88 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
89 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
90 extt = os.path.splitext(pout)
92 tnow = datetime.datetime.now()
96 tnow = datetime.datetime.now()
98 rectime = dt.seconds-10
99 rectime = str(rectime)
100 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
101 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
102 aviin = tsout + ".ts"
105 if re.search("5",opt):
107 if re.search("d",opt):
109 if re.search("\[二\]", pout):
111 elif re.search('(二)', pout):
113 elif re.search('\(二\)', pout):
117 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
121 elif chtxt == "hisch":
130 dualaudiots2avi(aviin, tsout + "sa.avi")
131 aviin = tsout + "sa.avi"
133 dualaudiots2avi(aviin, tsout + "sa.avi")
134 aviin = tsout + "sa.avi"
135 def ts2avi(pin,pout,opt):
136 status.setEncoding(status.getEncoding()+1)
137 if re.search("x",opt):
139 ts2xvid.ts2xvid(pin, pout, opt)
144 ts2x264.ts2x264(pin, pout, opt)
147 status.setEncoding(status.getEncoding()-1)
148 def tv2avi(pout, chtxt, btime, etime,opt):
149 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
150 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
154 extt = os.path.splitext(pout)
156 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
157 aviin = tsout + ".ts"
160 if re.search("5",opt):
162 if re.search("d",opt):
164 if re.search('\[二\]', pout):
166 elif re.search('(二)', pout):
168 elif re.search('\(二\)', pout):
171 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
175 elif chtxt == "hisch":
182 dualaudiots2avi(aviin, tsout + "sa.avi")
183 aviin = tsout + "sa.avi"
185 dualaudiots2avi(aviin, tsout + "sa.avi")
186 aviin = tsout + "sa.avi"
187 ts2x264.ts2x264(aviin, pout,opts)
189 def b252avi(pout, chtxt,opt):
190 extt = os.path.splitext(pout)
192 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
193 aviin = tsout + ".ts"
196 if re.search("5",opt):
198 if re.search("d",opt):
200 if re.search('\[二\]', pout):
202 elif re.search('(二)', pout):
204 elif re.search('\(二\)', pout):
208 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
212 elif chtxt == "hisch":
220 if re.search("x",opt):
225 dualaudiots2avi(aviin, tsout + "sa.avi")
226 aviin = tsout + "sa.avi"
228 dualaudiots2avi(aviin, tsout + "sa.avi")
229 aviin = tsout + "sa.avi"
231 ts2xvid.ts2xvid(aviin, pout,opts)
233 ts2x264.ts2x264(aviin, pout,opts)
234 def dualaudiots2avi(pin, pout):
235 bontsdemux = configreader.getpath('bontsdemux')
236 bonpin = "Z:\\" + pin[1:]
237 outf = os.path.splitext(pin)[0]
238 bonpout = "Z:\\" + outf[1:]
239 xvfb = configreader.getpath('xvfb-run')
240 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
242 exe = xvfb+' -a ' + exe
245 ffpin1 = pin.replace("ts", "wav")
246 ffpin2 = pin.replace("ts", "m2v")
247 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
249 #commands.getoutput(exe)
253 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"
262 exe = xvfb+' -a ' + exe
263 #exe = 'xvfb-run -a -e xvfberror.txt ' + exe
264 #exe='export Display=:2&&'+exe
266 commands.getoutput(exe)
268 ffpin=pin.replace(".ts","")
269 ffpin1 = pin.replace("ts", "wav")
270 ffpin2 = pin.replace("ts", "m2v")
271 ffpout1=ffpin+"1_delay"+delay+".wav"
272 ffpout2=ffpin+"2_delay"+delay+".wav"
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 ffpout21=ffpout1.replace(".wav",".ogg")
281 ffpout22=ffpout2.replace(".wav",".ogg")
282 aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
283 aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
286 commands.getoutput(aexe1)
287 commands.getoutput(aexe2)
288 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
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"
302 exe = xvfb+' -a ' + exe
303 #exe = 'xvfb-run -a ' + exe
304 #exe='export Display=:2&&'+exe
306 commands.getoutput(exe)
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 + "\'"
312 commands.getoutput(exe)