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()
44 tnow = datetime.datetime.now()
46 rectime = dt.seconds-10
47 rectime = str(rectime)
48 tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
49 def b252ts(pout, chtxt, btime, etime, opt):
51 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
53 #status.setB25Decoding(status.getB25Decoding() + 1)
54 status.changeB25Decoding(1)
56 tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
61 if re.search("5", opt):
63 if re.search("d", opt):
65 if re.search(u"\[二\]", pout):
67 elif re.search(u'(二)', pout):
69 elif re.search(u'\(二\)', pout):
72 dualaudio2sep(aviin,"167")
75 except Exception, inst:
76 recdblist.printutf8("Error happened in b252ts in tv2avi")
77 recdblist.printutf8(str(type(inst)))
78 recdblist.printutf8(str(inst))
79 status.changeB25Decoding(-1)
80 def ts2avi(pin, pout, opt):
81 status.changeEncoding(1)
83 ts2x264.ts2x264(pin, pout, opt)
84 except Exception, inst:
85 recdblist.printutf8("error occures in tv2avi.py ts2avi")
86 recdblist.printutf8(str(type(inst)))
87 recdblist.printutf8(str(inst))
88 status.changeEncoding(-1)
89 def ts2raw(pin, pout, opt):
90 status.changeEncoding(1)
92 ts2x264.ts2x264(pin, pout, opt)
93 except Exception, inst:
94 recdblist.printutf8("error occures in tv2avi.py ts2raw")
95 recdblist.printutf8(str(type(inst)))
96 recdblist.printutf8(str(inst))
97 status.changeEncoding(-1)
98 def dualaudiots2avi(pin, pout):
99 bontsdemux = configreader.getpath('bontsdemux')
100 bonpin = "Z:\\" + pin[1:]
101 outf = os.path.splitext(pin)[0]
102 bonpout = "Z:\\" + outf[1:]
103 xvfb = configreader.getpath('xvfb-run')
104 logpath=pin.replace("ts","log")
105 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
106 #recdblist.printutf8(exe)
107 exe = xvfb + ' -a ' + exe
108 recdblist.printutf8(exe)
109 os.system(exe.encode('utf-8'))
110 ffpin1 = pin.replace("ts", "wav")
111 ffpin2 = pin.replace("ts", "m2v")
112 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
113 recdblist.printutf8(exe)
114 #commands.getoutput(exe)
115 os.system(exe.encode('utf-8'))
118 def dualaudio2sep(pin, delay):
122 bontsdemux = configreader.getpath('bontsdemux')
123 wine = configreader.getpath('wine')
124 xvfb = configreader.getpath('xvfb-run')
125 bonpin = "Z:\\" + pin[1:]
126 outf = os.path.splitext(pin)[0]
127 bonpout = "Z:\\" + outf[1:]
128 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
129 exe = xvfb + ' -a ' + exe
130 recdblist.printutf8(exe)
131 txt=commands.getoutput(exe.encode('utf-8'))
133 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
136 ffpin = pin.replace(".ts", "")
137 ffpin1 = pin.replace("ts", "wav")
138 ffpin2 = pin.replace("ts", "m2v")
139 ffpout1 = ffpin + "_1.wav"
140 ffpout2 = ffpin + "_2.wav"
141 ffpout3 = ffpin + ".m2v"
142 shutil.move(ffpin1, ffpout1)
143 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
144 exe = xvfb + ' -a ' + exe
145 recdblist.printutf8(exe)
146 txt=commands.getoutput(exe.encode('utf-8'))
148 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
152 shutil.move(ffpin1, ffpout2)
153 shutil.move(ffpin2, ffpout3)
154 ffpout21=ffpout1.replace(".wav",".mp3")
155 ffpout22=ffpout2.replace(".wav",".mp3")
158 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
163 ffpout21=ffpout1.replace(".wav",".aac")
164 ffpout22=ffpout2.replace(".wav",".aac")
165 tv2audio.wav2aac_nero(ffpout1, ffpout21)
166 tv2audio.wav2aac_nero(ffpout2, ffpout22)
168 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
169 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
173 def pentaaudio2sep(pin):
174 bontsdemux = configreader.getpath('bontsdemux')
175 wine = configreader.getpath('wine')
176 xvfb = configreader.getpath('xvfb-run')
177 bonpin = "Z:\\" + pin[1:]
178 outf = os.path.splitext(pin)[0]
179 bonpout = "Z:\\" + outf[1:]
180 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
181 exe = xvfb + ' -a ' + exe
182 recdblist.printutf8(exe)
183 txt=commands.getoutput(exe.encode('utf-8'))
185 recdblist.addlog(pin, txt, "pentaaudio-sep1 BontsDemux")
188 ffpin = pin.replace(".ts", "")
189 ffpin1 = pin.replace("ts", "wav")
190 ffpin2 = pin.replace("ts", "m2v")
191 ffpout1 = ffpin + "_1.wav"
192 ffpout2 = ffpin + "_2.aac"
193 shutil.move(ffpin1, ffpout1)
194 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
195 exe = xvfb + ' -a ' + exe
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 bonpin = "Z:\\" + pin[1:]
237 xvfb = configreader.getpath('xvfb-run')
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: