3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
25 def timetv2avi(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 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
41 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
45 if re.search("5",opt):
47 if re.search("d",opt):
49 if re.search("\[二\]", pout):
51 elif re.search('(二)', pout):
53 elif re.search('\(二\)', pout):
57 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
61 elif chtxt == "hisch":
69 if re.search("x",opt):
74 dualaudiots2avi(aviin, tsout + "sa.avi")
75 aviin = tsout + "sa.avi"
77 dualaudiots2avi(aviin, tsout + "sa.avi")
78 aviin = tsout + "sa.avi"
81 ts2xvid.ts2xvid(aviin, pout,opts)
83 ts2x264.ts2x264(aviin, pout,opts)
85 bt=datetime.datetime.now()+datetime.timedelta(seconds=600)
86 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
87 et=datetime.datetime.now()+datetime.timedelta(seconds=600)
88 etime=et.strftime("%Y-%m-%d %H:%M:%S")
89 title=os.path.split(tsout)[1]
94 def tv2avi(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")
100 extt = os.path.splitext(pout)
104 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+time
105 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
106 aviin = tsout + ".ts"
109 if re.search("5",opt):
111 if re.search("d",opt):
113 if re.search('\[二\]', pout):
115 elif re.search('(二)', pout):
117 elif re.search('\(二\)', pout):
120 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
124 elif chtxt == "hisch":
131 dualaudiots2avi(aviin, tsout + "sa.avi")
132 aviin = tsout + "sa.avi"
134 dualaudiots2avi(aviin, tsout + "sa.avi")
135 aviin = tsout + "sa.avi"
136 ts2x264.ts2x264(aviin, pout,opts)
138 def b252avi(pout, chtxt,opt):
139 #bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
140 #et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
141 extt = os.path.splitext(pout)
145 #tnow = datetime.datetime.now()
147 #waitt = wt.seconds-5
149 #tnow = datetime.datetime.now()
151 #rectime = dt.seconds-10
152 #rectime = str(rectime)
153 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
154 #tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
155 aviin = tsout + ".ts"
158 if re.search("5",opt):
160 if re.search("d",opt):
162 if re.search('\[二\]', pout):
164 elif re.search('(二)', pout):
166 elif re.search('\(二\)', pout):
170 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
174 elif chtxt == "hisch":
182 if re.search("x",opt):
187 dualaudiots2avi(aviin, tsout + "sa.avi")
188 aviin = tsout + "sa.avi"
190 dualaudiots2avi(aviin, tsout + "sa.avi")
191 aviin = tsout + "sa.avi"
193 ts2xvid.ts2xvid(aviin, pout,opts)
195 ts2x264.ts2x264(aviin, pout,opts)
202 pout = pout.encode('utf-8')
203 extt = os.path.splitext(pout)
205 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+time
206 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
207 aviin = tsout + ".ts"
209 if re.search("d",opt):
211 if re.search('\[二\]', pout):
213 elif re.search('(二)', pout):
215 elif re.search('\(二\)', pout):
218 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
222 elif chtxt == "hisch":
229 dualaudiots2avi(aviin, tsout + "sa.avi")
230 aviin = tsout + "sa.avi"
231 ts2x264.ts2x264(aviin, pout,opts)
236 def dualaudiots2avi(pin, pout):
237 bontsdemux = configreader.getpath('bontsdemux')
238 wine = configreader.getpath('wine')
239 cmdwine = configreader.getpath('cmdwine')
240 bonpin = "Z:\\" + pin[1:]
241 outf = os.path.splitext(pin)[0]
242 bonpout = "Z:\\" + outf[1:]
243 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
245 exe = 'xvfb-run -a ' + exe
246 #exe='export Display=:2&&'+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 + "\'"
257 def pentaaudiots2avi(pin, pout):
258 bontsdemux = configreader.getpath('bontsdemux')
259 wine = configreader.getpath('wine')
260 cmdwine = configreader.getpath('cmdwine')
261 bonpin = "Z:\\" + pin[1:]
262 outf = os.path.splitext(pin)[0]
263 bonpout = "Z:\\" + outf[1:]
264 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
266 exe = 'xvfb-run -a ' + exe
267 #exe='export Display=:2&&'+exe
270 ffpin1 = pin.replace("ts", "wav")
271 ffpin2 = pin.replace("ts", "m2v")
272 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"