3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
25 def timetv2b25(pout, chtxt, btime, etime,opt):
26 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
27 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
28 extt = os.path.splitext(pout)
32 tnow = datetime.datetime.now()
36 tnow = datetime.datetime.now()
38 rectime = dt.seconds-10
39 rectime = str(rectime)
40 tv2ts.tv2b25ts(tsout+".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
41 def b252ts(pout,chtxt,btime,etime,opt):
42 tv2ts.b252ts(pout+".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
46 if re.search("5",opt):
48 if re.search("d",opt):
50 if re.search("\[二\]", pout):
52 elif re.search('(二)', pout):
54 elif re.search('\(二\)', pout):
58 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
62 elif chtxt == "hisch":
70 if re.search("x",opt):
75 dualaudiots2avi(aviin, tsout + "sa.avi")
76 aviin = tsout + "sa.avi"
78 dualaudiots2avi(aviin, tsout + "sa.avi")
79 aviin = tsout + "sa.avi"
80 def timetv2avi(pout, chtxt, btime, etime,opt):
81 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
82 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
83 extt = os.path.splitext(pout)
87 tnow = datetime.datetime.now()
91 tnow = datetime.datetime.now()
93 rectime = dt.seconds-10
94 rectime = str(rectime)
95 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
96 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
100 if re.search("5",opt):
102 if re.search("d",opt):
104 if re.search("\[二\]", pout):
106 elif re.search('(二)', pout):
108 elif re.search('\(二\)', pout):
112 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
116 elif chtxt == "hisch":
124 if re.search("x",opt):
129 dualaudiots2avi(aviin, tsout + "sa.avi")
130 aviin = tsout + "sa.avi"
132 dualaudiots2avi(aviin, tsout + "sa.avi")
133 aviin = tsout + "sa.avi"
134 bt=datetime.datetime.now()+datetime.timedelta(seconds=600)
135 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
136 et=datetime.datetime.now()+datetime.timedelta(seconds=600)
137 etime=et.strftime("%Y-%m-%d %H:%M:%S")
138 title=os.path.split(tsout)[1]
143 def tv2avi(pout, chtxt, btime, etime,opt):
144 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
145 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
149 extt = os.path.splitext(pout)
151 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
152 aviin = tsout + ".ts"
155 if re.search("5",opt):
157 if re.search("d",opt):
159 if re.search('\[二\]', pout):
161 elif re.search('(二)', pout):
163 elif re.search('\(二\)', pout):
166 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
170 elif chtxt == "hisch":
177 dualaudiots2avi(aviin, tsout + "sa.avi")
178 aviin = tsout + "sa.avi"
180 dualaudiots2avi(aviin, tsout + "sa.avi")
181 aviin = tsout + "sa.avi"
182 ts2x264.ts2x264(aviin, pout,opts)
184 def b252avi(pout, chtxt,opt):
185 extt = os.path.splitext(pout)
187 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
188 aviin = tsout + ".ts"
191 if re.search("5",opt):
193 if re.search("d",opt):
195 if re.search('\[二\]', pout):
197 elif re.search('(二)', pout):
199 elif re.search('\(二\)', pout):
203 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
207 elif chtxt == "hisch":
215 if re.search("x",opt):
220 dualaudiots2avi(aviin, tsout + "sa.avi")
221 aviin = tsout + "sa.avi"
223 dualaudiots2avi(aviin, tsout + "sa.avi")
224 aviin = tsout + "sa.avi"
226 ts2xvid.ts2xvid(aviin, pout,opts)
228 ts2x264.ts2x264(aviin, pout,opts)
234 def dualaudiots2avi(pin, pout):
235 bontsdemux = configreader.getpath('bontsdemux')
236 wine = configreader.getpath('wine')
237 bonpin = "Z:\\" + pin[1:]
238 outf = os.path.splitext(pin)[0]
239 bonpout = "Z:\\" + outf[1:]
240 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
242 exe = 'xvfb-run -a ' + exe
243 #exe='export Display=:2&&'+exe
246 ffpin1 = pin.replace("ts", "wav")
247 ffpin2 = pin.replace("ts", "m2v")
248 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
253 def dualaudio2sep(pin,pout,delay):
254 bontsdemux = configreader.getpath('bontsdemux')
255 wine = configreader.getpath('wine')
256 bonpin = "Z:\\" + pin[1:]
257 outf = os.path.splitext(pin)[0]
258 bonpout = "Z:\\" + outf[1:]
259 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
261 exe = 'xvfb-run -a ' + exe
262 #exe='export Display=:2&&'+exe
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 shutil.move(ffpin1, ffpout1)
271 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
272 exe = 'xvfb-run -a ' + exe
274 shutil.move(ffpin1, ffpout2)
275 ffpout21=ffpout1.replace(".wav",".ogg")
276 ffpout22=ffpout2.replace(".wav",".ogg")
277 aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
278 aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
282 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
288 def pentaaudiots2avi(pin, pout):
289 bontsdemux = configreader.getpath('bontsdemux')
290 wine = configreader.getpath('wine')
291 bonpin = "Z:\\" + pin[1:]
292 outf = os.path.splitext(pin)[0]
293 bonpout = "Z:\\" + outf[1:]
294 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
296 exe = 'xvfb-run -a ' + exe
297 #exe='export Display=:2&&'+exe
300 ffpin1 = pin.replace("ts", "wav")
301 ffpin2 = pin.replace("ts", "m2v")
302 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"