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.Commonlogex("Error", "b252ts(tv2avi.py)", str(type(inst)), str(inst))
83 status.changeB25Decoding(-1)
84 def ts2avi(pin, pout, opt):
85 status.changeEncoding(1)
87 ts2x264.ts2x264(pin, pout, opt)
88 except Exception, inst:
89 recdblist.printutf8("error occures in tv2avi.py ts2avi")
90 recdblist.printutf8(str(type(inst)))
91 recdblist.printutf8(str(inst))
92 status.changeEncoding(-1)
93 def ts2raw(pin, pout, opt):
94 status.changeEncoding(1)
96 ts2x264.ts2x264(pin, pout, opt)
97 except Exception, inst:
98 recdblist.printutf8("error occures in tv2avi.py ts2raw")
99 recdblist.printutf8(str(type(inst)))
100 recdblist.printutf8(str(inst))
101 status.changeEncoding(-1)
102 def dualaudio2sep(pin, delay):
106 xvfb = configreader.getpath('xvfb-run')
107 bontsdemux = configreader.getpath('bontsdemux')
108 wine = configreader.getpath('wine')
109 bonpin = "Z:\\" + pin[1:]
110 outf = os.path.splitext(pin)[0]
111 bonpout = "Z:\\" + outf[1:]
112 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
113 recdblist.printutf8(exe)
114 exe = xvfb + ' -a ' + exe
115 txt=commands.getoutput(exe.encode('utf-8'))
117 recdblist.addCommandLog(pin, u"BonTsDemux 第一音声取り出し", exe, txt)
120 ffpin = pin.replace(".ts", "")
121 ffpin1 = pin.replace("ts", "wav")
122 ffpin2 = pin.replace("ts", "m2v")
123 ffpout1 = ffpin + "_1.wav"
124 ffpout2 = ffpin + "_2.wav"
125 ffpout3 = ffpin + ".m2v"
126 shutil.move(ffpin1, ffpout1)
127 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
128 recdblist.printutf8(exe)
129 exe = xvfb + ' -a ' + exe
130 txt=commands.getoutput(exe.encode('utf-8'))
132 recdblist.addCommandLog(pin, u"BonTsDemux 第二音声取り出し", exe, txt)
136 shutil.move(ffpin1, ffpout2)
137 shutil.move(ffpin2, ffpout3)
138 ffpout21=ffpout1.replace(".wav",".mp3")
139 ffpout22=ffpout2.replace(".wav",".mp3")
142 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
147 ffpout21=ffpout1.replace(".wav",".aac")
148 ffpout22=ffpout2.replace(".wav",".aac")
149 tv2audio.wav2aac_nero(ffpout1, ffpout21)
150 tv2audio.wav2aac_nero(ffpout2, ffpout22)
152 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
153 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
157 def pentaaudio2sep(pin):
158 bontsdemux = configreader.getpath('bontsdemux')
159 wine = configreader.getpath('wine')
160 xvfb = configreader.getpath('xvfb-run')
161 bonpin = "Z:\\" + pin[1:]
162 outf = os.path.splitext(pin)[0]
163 bonpout = "Z:\\" + outf[1:]
164 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
165 exe = xvfb + ' -a ' + exe
166 recdblist.printutf8(exe)
167 txt=commands.getoutput(exe.encode('utf-8'))
169 recdblist.addCommandLog(pin, u"BonTsDemux5.1ch 第一音声取り出し", exe, txt)
172 ffpin = pin.replace(".ts", "")
173 ffpin1 = pin.replace("ts", "wav")
174 ffpin2 = pin.replace("ts", "m2v")
175 ffpout1 = ffpin + "_1.wav"
176 ffpout2 = ffpin + "_2.aac"
177 shutil.move(ffpin1, ffpout1)
178 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
179 recdblist.printutf8(exe)
180 txt=commands.getoutput(exe.encode('utf-8'))
182 recdblist.addCommandLog(pin, u"FFmpeg 5.1ch 第二音声(raw AAC)取り出し", exe, txt)
185 ffpout21=ffpout1.replace(".wav",".mp3")
188 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
193 ffpout21=ffpout1.replace(".wav",".aac")
194 tv2audio.wav2aac_nero(ffpout1, ffpout21)
196 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
197 if not os.path.exists(ffpout21):
198 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
199 exe = xvfb + ' -a ' + exe
200 recdblist.printutf8(exe)
201 txt=commands.getoutput(exe.encode('utf-8'))
203 recdblist.addCommandLog(pin, u"BonTsDemux 修正版第二音声(2chDownmix)取り出し", exe, txt)
206 shutil.move(ffpin1, ffpout1)
208 ffpout21=ffpout1.replace(".wav",".aac")
209 tv2audio.wav2aac_nero(ffpout1, ffpout21)
211 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
213 ffpout21=ffpout1.replace(".wav",".aac")
214 if os.path.exists(ffpout21):
215 if os.path.getsize(ffpout21)>10*1000*1000:
218 def singleaudio2sep(pin):
219 bontsdemux = configreader.getpath('bontsdemux')
220 wine = configreader.getpath('wine')
221 xvfb = configreader.getpath('xvfb-run')
222 bonpin = "Z:\\" + pin[1:]
223 outf = os.path.splitext(pin)[0]
224 bonpout = "Z:\\" + outf[1:]
225 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
226 exe = xvfb + ' -a ' + exe
227 recdblist.printutf8(exe)
228 txt=commands.getoutput(exe.encode('utf-8'))
230 recdblist.addCommandLog(pin, u"BonTsDemux 音声(wav化)取り出し", exe, txt)
233 ffpin = pin.replace(".ts", "")
234 ffpin1 = pin.replace("ts", "wav")
235 ffpin2 = pin.replace("ts", "m2v")
236 ffpout1 = ffpin + "_1.wav"
237 ffpout2 = ffpin + "_2.aac"
238 shutil.move(ffpin1, ffpout1)
239 exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
240 recdblist.printutf8(exe)
241 txt=commands.getoutput(exe.encode('utf-8'))
243 recdblist.addCommandLog(pin, u"FFmpeg 音声(raw AAC)取り出し", exe, txt)
246 ffpout21=ffpout1.replace(".wav",".mp3")
249 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
254 ffpout21=ffpout1.replace(".wav",".aac")
255 tv2audio.wav2aac_nero(ffpout1, ffpout21)
257 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
258 ffpout21=ffpout1.replace(".wav",".aac")
259 if os.path.exists(ffpout21):
260 if os.path.getsize(ffpout21)>10*1000*1000: