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'])
63 if re.search("5", opt):
65 if re.search("d", opt):
67 if re.search(u"\[二\]", pout):
69 elif re.search(u'(二)', pout):
71 elif re.search(u'\(二\)', pout):
73 elif re.search("b",opt):
76 dualaudio2sep(aviin,"167")
79 if singleaudiosplit ==1:
80 singleaudio2sep(aviin)
81 except Exception, inst:
82 recdblist.printutf8("Error happened in b252ts in tv2avi")
83 recdblist.printutf8(str(type(inst)))
84 recdblist.printutf8(str(inst))
85 status.changeB25Decoding(-1)
86 def ts2avi(pin, pout, opt):
87 status.changeEncoding(1)
89 ts2x264.ts2x264(pin, pout, opt)
90 except Exception, inst:
91 recdblist.printutf8("error occures in tv2avi.py ts2avi")
92 recdblist.printutf8(str(type(inst)))
93 recdblist.printutf8(str(inst))
94 status.changeEncoding(-1)
95 def ts2raw(pin, pout, opt):
96 status.changeEncoding(1)
98 ts2x264.ts2x264(pin, pout, opt)
99 except Exception, inst:
100 recdblist.printutf8("error occures in tv2avi.py ts2raw")
101 recdblist.printutf8(str(type(inst)))
102 recdblist.printutf8(str(inst))
103 status.changeEncoding(-1)
104 def dualaudio2sep(pin, delay):
108 xvfb = configreader.getpath('xvfb-run')
109 bontsdemux = configreader.getpath('bontsdemux')
110 wine = configreader.getpath('wine')
111 bonpin = "Z:\\" + pin[1:]
112 outf = os.path.splitext(pin)[0]
113 bonpout = "Z:\\" + outf[1:]
114 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
115 recdblist.printutf8(exe)
116 exe = xvfb + ' -a ' + exe
117 txt=commands.getoutput(exe.encode('utf-8'))
119 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
122 ffpin = pin.replace(".ts", "")
123 ffpin1 = pin.replace("ts", "wav")
124 ffpin2 = pin.replace("ts", "m2v")
125 ffpout1 = ffpin + "_1.wav"
126 ffpout2 = ffpin + "_2.wav"
127 ffpout3 = ffpin + ".m2v"
128 shutil.move(ffpin1, ffpout1)
129 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -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")
138 shutil.move(ffpin1, ffpout2)
139 shutil.move(ffpin2, ffpout3)
140 ffpout21=ffpout1.replace(".wav",".mp3")
141 ffpout22=ffpout2.replace(".wav",".mp3")
144 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
149 ffpout21=ffpout1.replace(".wav",".aac")
150 ffpout22=ffpout2.replace(".wav",".aac")
151 tv2audio.wav2aac_nero(ffpout1, ffpout21)
152 tv2audio.wav2aac_nero(ffpout2, ffpout22)
154 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
155 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
159 def pentaaudio2sep(pin):
160 bontsdemux = configreader.getpath('bontsdemux')
161 wine = configreader.getpath('wine')
162 xvfb = configreader.getpath('xvfb-run')
163 bonpin = "Z:\\" + pin[1:]
164 outf = os.path.splitext(pin)[0]
165 bonpout = "Z:\\" + outf[1:]
166 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
167 exe = xvfb + ' -a ' + exe
168 recdblist.printutf8(exe)
169 txt=commands.getoutput(exe.encode('utf-8'))
171 recdblist.addlog(pin, txt, "pentaaudio-sep1 BontsDemux")
174 ffpin = pin.replace(".ts", "")
175 ffpin1 = pin.replace("ts", "wav")
176 ffpin2 = pin.replace("ts", "m2v")
177 ffpout1 = ffpin + "_1.wav"
178 ffpout2 = ffpin + "_2.aac"
179 shutil.move(ffpin1, ffpout1)
180 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
181 recdblist.printutf8(exe)
182 txt=commands.getoutput(exe.encode('utf-8'))
184 recdblist.addlog(pin, txt, "pentaaudio-sep2(raw aac) ffmpeg")
187 ffpout21=ffpout1.replace(".wav",".mp3")
190 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
195 ffpout21=ffpout1.replace(".wav",".aac")
196 tv2audio.wav2aac_nero(ffpout1, ffpout21)
198 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
199 if not os.path.exists(ffpout21):
200 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
201 exe = xvfb + ' -a ' + exe
202 recdblist.printutf8(exe)
203 txt=commands.getoutput(exe.encode('utf-8'))
205 recdblist.addlog(pin, txt, "pentaaudio-sep Downmix (5.1ch error) BontsDemux")
208 shutil.move(ffpin1, ffpout1)
210 ffpout21=ffpout1.replace(".wav",".aac")
211 tv2audio.wav2aac_nero(ffpout1, ffpout21)
213 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
215 ffpout21=ffpout1.replace(".wav",".aac")
216 if os.path.exists(ffpout21):
217 if os.path.getsize(ffpout21)>10*1000*1000:
220 def singleaudio2sep(pin):
221 bontsdemux = configreader.getpath('bontsdemux')
222 wine = configreader.getpath('wine')
223 xvfb = configreader.getpath('xvfb-run')
224 bonpin = "Z:\\" + pin[1:]
225 outf = os.path.splitext(pin)[0]
226 bonpout = "Z:\\" + outf[1:]
227 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
228 exe = xvfb + ' -a ' + exe
229 recdblist.printutf8(exe)
230 txt=commands.getoutput(exe.encode('utf-8'))
232 recdblist.addlog(pin, txt, "singleaaudio-sep1 BontsDemux")
235 ffpin = pin.replace(".ts", "")
236 ffpin1 = pin.replace("ts", "wav")
237 ffpin2 = pin.replace("ts", "m2v")
238 ffpout1 = ffpin + "_1.wav"
239 ffpout2 = ffpin + "_2.aac"
240 shutil.move(ffpin1, ffpout1)
241 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
242 recdblist.printutf8(exe)
243 txt=commands.getoutput(exe.encode('utf-8'))
245 recdblist.addlog(pin, txt, "singleaudio-sep2(raw aac) ffmpeg")
248 ffpout21=ffpout1.replace(".wav",".mp3")
251 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
256 ffpout21=ffpout1.replace(".wav",".aac")
257 tv2audio.wav2aac_nero(ffpout1, ffpout21)
259 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
260 ffpout21=ffpout1.replace(".wav",".aac")
261 if os.path.exists(ffpout21):
262 if os.path.getsize(ffpout21)>10*1000*1000: