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)
48 status.changeB25Decoding(1)
50 tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
55 if re.search("5", opt):
57 if re.search("d", opt):
59 if re.search("\[二\]", pout):
61 elif re.search('(二)', pout):
63 elif re.search('\(二\)', pout):
67 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
71 elif chtxt == "hisch":
80 dualaudiots2avi(aviin, tsout + "sa.avi")
81 aviin = tsout + "sa.avi"
83 dualaudiots2avi(aviin, tsout + "sa.avi")
84 aviin = tsout + "sa.avi"
87 #status.setB25Decoding(status.getB25Decoding()-1)
88 status.changeB25Decoding(-1)
89 def timetv2avi(pout, chtxt, btime, etime, opt):
90 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
91 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
92 extt = os.path.splitext(pout)
94 tnow = datetime.datetime.now()
98 tnow = datetime.datetime.now()
100 rectime = dt.seconds-10
101 rectime = str(rectime)
102 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
103 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
104 aviin = tsout + ".ts"
107 if re.search("5", opt):
109 if re.search("d", opt):
111 if re.search("\[二\]", pout):
113 elif re.search('(二)', pout):
115 elif re.search('\(二\)', pout):
119 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
123 elif chtxt == "hisch":
132 dualaudiots2avi(aviin, tsout + "sa.avi")
133 aviin = tsout + "sa.avi"
135 dualaudiots2avi(aviin, tsout + "sa.avi")
136 aviin = tsout + "sa.avi"
137 def ts2avi(pin, pout, opt):
138 status.changeEncoding(1)
139 #status.setEncoding(status.getEncoding() + 1)
140 if re.search("x", opt):
142 ts2xvid.ts2xvid(pin, pout, opt)
147 ts2x264.ts2x264(pin, pout, opt)
150 status.changeEncoding(-1)
151 #status.setEncoding(status.getEncoding()-1)
152 def tv2avi(pout, chtxt, btime, etime, opt):
153 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
154 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
158 extt = os.path.splitext(pout)
160 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
161 aviin = tsout + ".ts"
164 if re.search("5", opt):
166 if re.search("d", opt):
168 if re.search('\[二\]', pout):
170 elif re.search('(二)', pout):
172 elif re.search('\(二\)', pout):
175 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
179 elif chtxt == "hisch":
186 dualaudiots2avi(aviin, tsout + "sa.avi")
187 aviin = tsout + "sa.avi"
189 dualaudiots2avi(aviin, tsout + "sa.avi")
190 aviin = tsout + "sa.avi"
191 ts2x264.ts2x264(aviin, pout, opts)
193 def b252avi(pout, chtxt, opt):
194 extt = os.path.splitext(pout)
196 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
197 aviin = tsout + ".ts"
200 if re.search("5", opt):
202 if re.search("d", opt):
204 if re.search('\[二\]', pout):
206 elif re.search('(二)', pout):
208 elif re.search('\(二\)', pout):
212 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
216 elif chtxt == "hisch":
224 if re.search("x", opt):
229 dualaudiots2avi(aviin, tsout + "sa.avi")
230 aviin = tsout + "sa.avi"
232 dualaudiots2avi(aviin, tsout + "sa.avi")
233 aviin = tsout + "sa.avi"
235 ts2xvid.ts2xvid(aviin, pout, opts)
237 ts2x264.ts2x264(aviin, pout, opts)
238 def dualaudiots2avi(pin, pout):
239 bontsdemux = configreader.getpath('bontsdemux')
240 bonpin = "Z:\\" + pin[1:]
241 outf = os.path.splitext(pin)[0]
242 bonpout = "Z:\\" + outf[1:]
243 xvfb = configreader.getpath('xvfb-run')
244 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
246 exe = xvfb + ' -a ' + exe
249 ffpin1 = pin.replace("ts", "wav")
250 ffpin2 = pin.replace("ts", "m2v")
251 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
253 #commands.getoutput(exe)
257 def dualaudio2sep(pin, pout, delay):
261 bontsdemux = configreader.getpath('bontsdemux')
262 wine = configreader.getpath('wine')
263 xvfb = configreader.getpath('xvfb-run')
264 bonpin = "Z:\\" + pin[1:]
265 outf = os.path.splitext(pin)[0]
266 bonpout = "Z:\\" + outf[1:]
267 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
269 exe = xvfb + ' -a ' + exe
271 commands.getoutput(exe)
272 ffpin = pin.replace(".ts", "")
273 ffpin1 = pin.replace("ts", "wav")
274 ffpin2 = pin.replace("ts", "m2v")
275 ffpout1 = ffpin + "1_delay" + delay + ".wav"
276 ffpout2 = ffpin + "2_delay" + delay + ".wav"
277 ffpout3 = ffpin + "_delay" + delay + ".m2v"
278 shutil.move(ffpin1, ffpout1)
279 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
280 exe = xvfb + ' -a ' + exe
282 commands.getoutput(exe)
284 shutil.move(ffpin1, ffpout2)
285 shutil.move(ffpin2, ffpout3)
286 #ffpout21=ffpout1.replace(".wav",".ogg")
287 #ffpout22=ffpout2.replace(".wav",".ogg")
288 #aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
289 #aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
290 aexe = "ffmpeg -i \"" + ffpout3 + "\" -i \"" + ffpout1 + "\" -i \"" + ffpout2 + "\" -r 29.97 -vsync 200 -vcodec copy -acodec copy -f avi " + pout + " -acodec copy -newaudio"
294 commands.getoutput(aexe)
295 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
301 def pentaaudiots2avi(pin, pout):
302 bontsdemux = configreader.getpath('bontsdemux')
303 bonpin = "Z:\\" + pin[1:]
304 xvfb = configreader.getpath('xvfb-run')
305 outf = os.path.splitext(pin)[0]
306 bonpout = "Z:\\" + outf[1:]
307 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
309 exe = xvfb + ' -a ' + exe
310 #exe = 'xvfb-run -a ' + exe
311 #exe='export Display=:2&&'+exe
313 commands.getoutput(exe)
315 ffpin1 = pin.replace("ts", "wav")
316 ffpin2 = pin.replace("ts", "m2v")
317 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
319 commands.getoutput(exe)