3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
26 def timetv2avi(pout, chtxt, btime, etime,opt):
27 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
28 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
29 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 #print tsout+".ts,"+chdb.chtxtsearch(chtxt)['ch']+","+chdb.chtxtsearch(chtxt)['csch']+","+rectime
42 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], rectime)
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 bt=datetime.datetime.now()+datetime.timedelta(seconds=600)
81 btime=bt.strftime("%Y-%m-%d %H:%M:%S")
82 et=datetime.datetime.now()+datetime.timedelta(seconds=600)
83 etime=et.strftime("%Y-%m-%d %H:%M:%S")
84 title=os.path.split(tsout)[1]
89 def tv2avi(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")
95 extt = os.path.splitext(pout)
97 tv2ts.tv2ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'], time)
101 if re.search("5",opt):
103 if re.search("d",opt):
105 if re.search('\[二\]', pout):
107 elif re.search('(二)', pout):
109 elif re.search('\(二\)', pout):
112 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
116 elif chtxt == "hisch":
123 dualaudiots2avi(aviin, tsout + "sa.avi")
124 aviin = tsout + "sa.avi"
126 dualaudiots2avi(aviin, tsout + "sa.avi")
127 aviin = tsout + "sa.avi"
128 ts2x264.ts2x264(aviin, pout,opts)
130 def b252avi(pout, chtxt,opt):
131 extt = os.path.splitext(pout)
133 tv2ts.b252ts(tsout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
134 aviin = tsout + ".ts"
137 if re.search("5",opt):
139 if re.search("d",opt):
141 if re.search('\[二\]', pout):
143 elif re.search('(二)', pout):
145 elif re.search('\(二\)', pout):
149 if chdb.chtxtsearch(chtxt)['bctype'] == 'cs':
153 elif chtxt == "hisch":
161 if re.search("x",opt):
166 dualaudiots2avi(aviin, tsout + "sa.avi")
167 aviin = tsout + "sa.avi"
169 dualaudiots2avi(aviin, tsout + "sa.avi")
170 aviin = tsout + "sa.avi"
172 ts2xvid.ts2xvid(aviin, pout,opts)
174 ts2x264.ts2x264(aviin, pout,opts)
180 def dualaudiots2avi(pin, pout):
181 bontsdemux = configreader.getpath('bontsdemux')
182 wine = configreader.getpath('wine')
183 bonpin = "Z:\\" + pin[1:]
184 outf = os.path.splitext(pin)[0]
185 bonpout = "Z:\\" + outf[1:]
186 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
188 exe = 'xvfb-run -a ' + exe
189 #exe='export Display=:2&&'+exe
192 ffpin1 = pin.replace("ts", "wav")
193 ffpin2 = pin.replace("ts", "m2v")
194 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
199 def dualaudio2sep(pin,pout,delay):
200 bontsdemux = configreader.getpath('bontsdemux')
201 wine = configreader.getpath('wine')
202 bonpin = "Z:\\" + pin[1:]
203 outf = os.path.splitext(pin)[0]
204 bonpout = "Z:\\" + outf[1:]
205 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
207 exe = 'xvfb-run -a ' + exe
208 #exe='export Display=:2&&'+exe
211 ffpin=pin.replace(".ts","")
212 ffpin1 = pin.replace("ts", "wav")
213 ffpin2 = pin.replace("ts", "m2v")
214 ffpout1=ffpin+"1_delay"+delay+".wav"
215 ffpout2=ffpin+"2_delay"+delay+".wav"
216 shutil.move(ffpin1, ffpout1)
217 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay "+delay+" -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
218 exe = 'xvfb-run -a ' + exe
220 shutil.move(ffpin1, ffpout2)
221 ffpout21=ffpout1.replace(".wav",".ogg")
222 ffpout22=ffpout2.replace(".wav",".ogg")
223 aexe1="ffmpeg -i "+ffpout1+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout21
224 aexe2="ffmpeg -i "+ffpout2+" -vn -acodec vorbis -ar 48000 -ab 128k "+ffpout22
228 #exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
234 def pentaaudiots2avi(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 3 -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 + "\'"