3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
32 def timetv2b25(pout, chtxt, btime, etime, opt):
36 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
37 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
38 extt = os.path.splitext(pout)
40 tnow = datetime.datetime.now()
45 tnow = datetime.datetime.now()
47 rectime = dt.seconds-5
48 rectime = str(rectime)
49 tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
50 def b252ts(pout, chtxt, btime, etime, opt):
52 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
54 #status.setB25Decoding(status.getB25Decoding() + 1)
55 status.changeB25Decoding(1)
57 tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
62 if re.search("5", opt):
64 if re.search("d", opt):
66 if re.search(u"\[二\]", pout):
68 elif re.search(u'(二)', pout):
70 elif re.search(u'\(二\)', pout):
73 dualaudio2sep(aviin,"167")
76 except Exception, inst:
77 recdblist.printutf8("Error happened in b252ts in tv2avi")
78 recdblist.printutf8(str(type(inst)))
79 recdblist.printutf8(str(inst))
80 status.changeB25Decoding(-1)
81 def ts2avi(pin, pout, opt):
82 status.changeEncoding(1)
84 ts2x264.ts2x264(pin, pout, opt)
85 except Exception, inst:
86 recdblist.printutf8("error occures in tv2avi.py ts2avi")
87 recdblist.printutf8(str(type(inst)))
88 recdblist.printutf8(str(inst))
89 status.changeEncoding(-1)
90 def ts2raw(pin, pout, opt):
91 status.changeEncoding(1)
93 ts2x264.ts2x264(pin, pout, opt)
94 except Exception, inst:
95 recdblist.printutf8("error occures in tv2avi.py ts2raw")
96 recdblist.printutf8(str(type(inst)))
97 recdblist.printutf8(str(inst))
98 status.changeEncoding(-1)
99 def dualaudiots2avi(pin, pout):
100 bontsdemux = configreader.getpath('bontsdemux')
101 bonpin = "Z:\\" + pin[1:]
102 outf = os.path.splitext(pin)[0]
103 bonpout = "Z:\\" + outf[1:]
104 xvfb = configreader.getpath('xvfb-run')
105 logpath=pin.replace("ts","log")
106 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
107 #recdblist.printutf8(exe)
108 exe = xvfb + ' -a ' + exe
109 recdblist.printutf8(exe)
110 os.system(exe.encode('utf-8'))
111 ffpin1 = pin.replace("ts", "wav")
112 ffpin2 = pin.replace("ts", "m2v")
113 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
114 recdblist.printutf8(exe)
115 #commands.getoutput(exe)
116 os.system(exe.encode('utf-8'))
119 def dualaudio2sep(pin, delay):
123 xvfb = configreader.getpath('xvfb-run')
124 bontsdemux = configreader.getpath('bontsdemux')
125 wine = configreader.getpath('wine')
126 bonpin = "Z:\\" + pin[1:]
127 outf = os.path.splitext(pin)[0]
128 bonpout = "Z:\\" + outf[1:]
129 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
130 recdblist.printutf8(exe)
131 exe = xvfb + ' -a ' + exe
132 txt=commands.getoutput(exe.encode('utf-8'))
134 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
137 ffpin = pin.replace(".ts", "")
138 ffpin1 = pin.replace("ts", "wav")
139 ffpin2 = pin.replace("ts", "m2v")
140 ffpout1 = ffpin + "_1.wav"
141 ffpout2 = ffpin + "_2.wav"
142 ffpout3 = ffpin + ".m2v"
143 shutil.move(ffpin1, ffpout1)
144 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
145 recdblist.printutf8(exe)
146 exe = xvfb + ' -a ' + exe
147 txt=commands.getoutput(exe.encode('utf-8'))
149 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
153 shutil.move(ffpin1, ffpout2)
154 shutil.move(ffpin2, ffpout3)
155 ffpout21=ffpout1.replace(".wav",".mp3")
156 ffpout22=ffpout2.replace(".wav",".mp3")
159 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
164 ffpout21=ffpout1.replace(".wav",".aac")
165 ffpout22=ffpout2.replace(".wav",".aac")
166 tv2audio.wav2aac_nero(ffpout1, ffpout21)
167 tv2audio.wav2aac_nero(ffpout2, ffpout22)
169 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
170 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
174 def pentaaudio2sep(pin):
175 bontsdemux = configreader.getpath('bontsdemux')
176 wine = configreader.getpath('wine')
177 xvfb = configreader.getpath('xvfb-run')
178 bonpin = "Z:\\" + pin[1:]
179 outf = os.path.splitext(pin)[0]
180 bonpout = "Z:\\" + outf[1:]
181 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
182 exe = xvfb + ' -a ' + exe
183 recdblist.printutf8(exe)
184 txt=commands.getoutput(exe.encode('utf-8'))
186 recdblist.addlog(pin, txt, "pentaaudio-sep1 BontsDemux")
189 ffpin = pin.replace(".ts", "")
190 ffpin1 = pin.replace("ts", "wav")
191 ffpin2 = pin.replace("ts", "m2v")
192 ffpout1 = ffpin + "_1.wav"
193 ffpout2 = ffpin + "_2.aac"
194 shutil.move(ffpin1, ffpout1)
195 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
196 recdblist.printutf8(exe)
197 txt=commands.getoutput(exe.encode('utf-8'))
199 recdblist.addlog(pin, txt, "pentaaudio-sep2(raw aac) ffmpeg")
202 ffpout21=ffpout1.replace(".wav",".mp3")
205 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
210 ffpout21=ffpout1.replace(".wav",".aac")
211 tv2audio.wav2aac_nero(ffpout1, ffpout21)
213 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
214 if not os.path.exists(ffpout21):
215 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
216 exe = xvfb + ' -a ' + exe
217 recdblist.printutf8(exe)
218 txt=commands.getoutput(exe.encode('utf-8'))
220 recdblist.addlog(pin, txt, "pentaaudio-sep Downmix (5.1ch error) BontsDemux")
223 shutil.move(ffpin1, ffpout1)
225 ffpout21=ffpout1.replace(".wav",".aac")
226 tv2audio.wav2aac_nero(ffpout1, ffpout21)
228 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
230 ffpout21=ffpout1.replace(".wav",".aac")
231 if os.path.exists(ffoput21):
232 if os.path.getsize(ffpout21)>10*1000*1000:
234 def pentaaudiots2avi(pin, pout):
235 bontsdemux = configreader.getpath('bontsdemux')
236 xvfb = configreader.getpath('xvfb-run')
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"
241 exe = xvfb + ' -a ' + exe
242 recdblist.printutf8(exe)
243 txt=u"Cmd : "+exe+"\n"
244 txt=txt+commands.getoutput(exe.encode('utf-8'))
245 recdblist.addlog(pin, txt, "5.1ch audio Demux log")
246 ffpin1 = pin.replace("ts", "wav")
247 ffpin2 = pin.replace("ts", "m2v")
250 exe = u"ffmpeg -y -i \"" + ffpin1 + u"\" -i \'" + ffpin2 + u"\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \"" + pout + "\""
251 recdblist.printutf8(exe)
252 txt=u"Cmd : "+exe+"\n"
253 txtt=commands.getoutput(exe.encode('utf-8'))
257 txt=txt+"skip logging (not UTF-8)"
258 recdblist.addlog(pin, txt, "5.1ch audio Mux log")
259 if os.path.exists(pout):
260 if os.path.getsize(pout)>100*1000: