3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
33 def timetv2b25(pout, chtxt, btime, etime, opt):
37 bt = datetime.datetime.strptime(btime, "%Y-%m-%d %H:%M:%S")
38 et = datetime.datetime.strptime(etime, "%Y-%m-%d %H:%M:%S")
39 extt = os.path.splitext(pout)
41 tnow = datetime.datetime.now()
46 tnow = datetime.datetime.now()
48 rectime = dt.seconds-5
49 rectime = str(rectime)
50 tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
51 def b252ts(pout, chtxt, btime, etime, opt):
53 poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
55 #status.setB25Decoding(status.getB25Decoding() + 1)
56 status.changeB25Decoding(1)
58 tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
64 if re.search("5", opt):
66 if re.search("d", opt):
68 if re.search(u"\[二\]", pout):
70 elif re.search(u'(二)', pout):
72 elif re.search(u'\(二\)', pout):
74 elif re.search("b",opt):
77 dualaudio2sep(aviin,"167")
80 if singleaudiosplit ==1:
81 singleaudio2sep(aviin)
82 except Exception, inst:
83 recdblist.Commonlogex("Error", "b252ts(tv2avi.py)", str(type(inst))+traceback.format_exc(), str(inst))
84 status.changeB25Decoding(-1)
85 def ts2avi(pin, pout, opt):
86 status.changeEncoding(1)
88 ts2x264.ts2x264(pin, pout, opt)
89 except Exception, inst:
90 recdblist.printutf8("error occures in tv2avi.py ts2avi")
91 recdblist.printutf8(str(type(inst)))
92 recdblist.printutf8(str(inst)+traceback.format_exc())
93 status.changeEncoding(-1)
94 def ts2raw(pin, pout, opt):
95 status.changeEncoding(1)
97 ts2x264.ts2x264(pin, pout, opt)
98 except Exception, inst:
99 recdblist.printutf8("error occures in tv2avi.py ts2raw")
100 recdblist.printutf8(str(type(inst)))
101 recdblist.printutf8(str(inst)+traceback.format_exc())
102 status.changeEncoding(-1)
103 def dualaudio2sep(pin, delay):
107 xvfb = configreader.getpath('xvfb-run')
108 bontsdemux = configreader.getpath('bontsdemux')
109 wine = configreader.getpath('wine')
110 bonpin = "Z:\\" + pin[1:]
111 outf = os.path.splitext(pin)[0]
112 bonpout = "Z:\\" + outf[1:]
113 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
114 recdblist.printutf8(exe)
115 exe = xvfb + ' -a ' + exe
116 txt=commands.getoutput(exe.encode('utf-8'))
118 recdblist.addCommandLog(pin, u"BonTsDemux 第一音声取り出し", exe, txt)
121 ffpin = pin.replace(".ts", "")
122 ffpin1 = pin.replace("ts", "wav")
123 ffpin2 = pin.replace("ts", "m2v")
124 ffpout1 = ffpin + "_1.wav"
125 ffpout2 = ffpin + "_2.wav"
126 ffpout3 = ffpin + ".m2v"
127 shutil.move(ffpin1, ffpout1)
128 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
129 recdblist.printutf8(exe)
130 exe = xvfb + ' -a ' + exe
131 txt=commands.getoutput(exe.encode('utf-8'))
133 recdblist.addCommandLog(pin, u"BonTsDemux 第二音声取り出し", exe, txt)
137 shutil.move(ffpin1, ffpout2)
138 shutil.move(ffpin2, ffpout3)
139 ffpout21=ffpout1.replace(".wav",".mp3")
140 ffpout22=ffpout2.replace(".wav",".mp3")
143 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
148 ffpout21=ffpout1.replace(".wav",".aac")
149 ffpout22=ffpout2.replace(".wav",".aac")
150 tv2audio.wav2aac_nero(ffpout1, ffpout21)
151 tv2audio.wav2aac_nero(ffpout2, ffpout22)
153 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
154 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
158 def pentaaudio2sep(pin):
159 bontsdemux = configreader.getpath('bontsdemux')
160 wine = configreader.getpath('wine')
161 xvfb = configreader.getpath('xvfb-run')
162 bonpin = "Z:\\" + pin[1:]
163 outf = os.path.splitext(pin)[0]
164 bonpout = "Z:\\" + outf[1:]
165 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
166 exe = xvfb + ' -a ' + exe
167 recdblist.printutf8(exe)
168 txt=commands.getoutput(exe.encode('utf-8'))
170 recdblist.addCommandLog(pin, u"BonTsDemux5.1ch 第一音声取り出し", exe, txt)
173 ffpin = pin.replace(".ts", "")
174 ffpin1 = pin.replace("ts", "wav")
175 ffpin2 = pin.replace("ts", "m2v")
176 ffpout1 = ffpin + "_1.wav"
177 ffpout2 = ffpin + "_2.aac"
178 shutil.move(ffpin1, ffpout1)
179 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
180 recdblist.printutf8(exe)
181 txt=commands.getoutput(exe.encode('utf-8'))
183 recdblist.addCommandLog(pin, u"FFmpeg 5.1ch 第二音声(raw AAC)取り出し", exe, txt)
186 ffpout21=ffpout1.replace(".wav",".mp3")
189 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
194 ffpout21=ffpout1.replace(".wav",".aac")
195 tv2audio.wav2aac_nero(ffpout1, ffpout21)
197 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
198 if not os.path.exists(ffpout21):
199 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
200 exe = xvfb + ' -a ' + exe
201 recdblist.printutf8(exe)
202 txt=commands.getoutput(exe.encode('utf-8'))
204 recdblist.addCommandLog(pin, u"BonTsDemux 修正版第二音声(2chDownmix)取り出し", exe, txt)
207 shutil.move(ffpin1, ffpout1)
209 ffpout21=ffpout1.replace(".wav",".aac")
210 tv2audio.wav2aac_nero(ffpout1, ffpout21)
212 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
214 ffpout21=ffpout1.replace(".wav",".aac")
215 if os.path.exists(ffpout21):
216 if os.path.getsize(ffpout21)>10*1000*1000:
219 def singleaudio2sep(pin):
220 bontsdemux = configreader.getpath('bontsdemux')
221 wine = configreader.getpath('wine')
222 xvfb = configreader.getpath('xvfb-run')
223 bonpin = "Z:\\" + pin[1:]
224 outf = os.path.splitext(pin)[0]
225 bonpout = "Z:\\" + outf[1:]
226 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
227 exe = xvfb + ' -a ' + exe
228 recdblist.printutf8(exe)
229 txt=commands.getoutput(exe.encode('utf-8'))
231 recdblist.addCommandLog(pin, u"BonTsDemux 音声(wav化)取り出し", exe, txt)
234 ffpin = pin.replace(".ts", "")
235 ffpin1 = pin.replace("ts", "wav")
236 ffpin2 = pin.replace("ts", "m2v")
237 ffpout1 = ffpin + "_1.wav"
238 ffpout2 = ffpin + "_2.aac"
239 shutil.move(ffpin1, ffpout1)
240 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
241 recdblist.printutf8(exe)
242 txt=commands.getoutput(exe.encode('utf-8'))
244 recdblist.addCommandLog(pin, u"FFmpeg 音声(raw AAC)取り出し", exe, txt)
247 ffpout21=ffpout1.replace(".wav",".mp3")
250 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
255 ffpout21=ffpout1.replace(".wav",".aac")
256 tv2audio.wav2aac_nero(ffpout1, ffpout21)
258 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
259 ffpout21=ffpout1.replace(".wav",".aac")
260 if os.path.exists(ffpout21):
261 if os.path.getsize(ffpout21)>10*1000*1000: