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")
74 pentaaudiots2avi(aviin, tsout + ".sa.avi")
75 except Exception, inst:
76 print "Error happened in b252ts in tv2avi"
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 print "error occures in tv2avi.py ts2avi"
88 status.changeEncoding(-1)
89 def dualaudiots2avi(pin, pout):
90 bontsdemux = configreader.getpath('bontsdemux')
91 bonpin = "Z:\\" + pin[1:]
92 outf = os.path.splitext(pin)[0]
93 bonpout = "Z:\\" + outf[1:]
94 xvfb = configreader.getpath('xvfb-run')
95 logpath=pin.replace("ts","log")
96 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
97 #recdblist.printutf8(exe)
98 exe = xvfb + ' -a ' + exe
99 recdblist.printutf8(exe)
100 os.system(exe.encode('utf-8'))
101 ffpin1 = pin.replace("ts", "wav")
102 ffpin2 = pin.replace("ts", "m2v")
103 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
104 recdblist.printutf8(exe)
105 #commands.getoutput(exe)
106 os.system(exe.encode('utf-8'))
109 def dualaudio2sep(pin, delay):
113 bontsdemux = configreader.getpath('bontsdemux')
114 wine = configreader.getpath('wine')
115 xvfb = configreader.getpath('xvfb-run')
116 bonpin = "Z:\\" + pin[1:]
117 outf = os.path.splitext(pin)[0]
118 bonpout = "Z:\\" + outf[1:]
119 exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
120 exe = xvfb + ' -a ' + exe
121 recdblist.printutf8(exe)
122 txt=commands.getoutput(exe.encode('utf-8'))
124 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
127 ffpin = pin.replace(".ts", "")
128 ffpin1 = pin.replace("ts", "wav")
129 ffpin2 = pin.replace("ts", "m2v")
130 ffpout1 = ffpin + "_1.wav"
131 ffpout2 = ffpin + "_2.wav"
132 ffpout3 = ffpin + ".m2v"
133 shutil.move(ffpin1, ffpout1)
134 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
135 exe = xvfb + ' -a ' + exe
136 recdblist.printutf8(exe)
137 txt=commands.getoutput(exe.encode('utf-8'))
139 recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
143 shutil.move(ffpin1, ffpout2)
144 shutil.move(ffpin2, ffpout3)
145 ffpout21=ffpout1.replace(".wav",".mp3")
146 ffpout22=ffpout2.replace(".wav",".mp3")
149 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
154 ffpout21=ffpout1.replace(".wav",".aac")
155 ffpout22=ffpout2.replace(".wav",".aac")
156 tv2audio.wav2aac_nero(ffpout1, ffpout21)
157 tv2audio.wav2aac_nero(ffpout2, ffpout22)
159 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
160 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
165 def pentaaudiots2avi(pin, pout):
166 bontsdemux = configreader.getpath('bontsdemux')
167 bonpin = "Z:\\" + pin[1:]
168 xvfb = configreader.getpath('xvfb-run')
169 outf = os.path.splitext(pin)[0]
170 bonpout = "Z:\\" + outf[1:]
171 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
172 exe = xvfb + ' -a ' + exe
173 recdblist.printutf8(exe)
174 txt=u"Cmd : "+exe+"\n"
175 txt=txt+commands.getoutput(exe.encode('utf-8'))
176 recdblist.addlog(pin, txt, "5.1ch audio Demux log")
177 ffpin1 = pin.replace("ts", "wav")
178 ffpin2 = pin.replace("ts", "m2v")
181 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 + "\""
182 recdblist.printutf8(exe)
183 txt=u"Cmd : "+exe+"\n"
184 txtt=commands.getoutput(exe.encode('utf-8'))
188 txt=txt+"skip logging (not UTF-8)"
189 recdblist.addlog(pin, txt, "5.1ch audio Mux log")
190 if os.path.exists(pout):
191 if os.path.getsize(pout)>100*1000: