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 commands.getoutput(exe.encode('utf-8'))
123 ffpin = pin.replace(".ts", "")
124 ffpin1 = pin.replace("ts", "wav")
125 ffpin2 = pin.replace("ts", "m2v")
126 ffpout1 = ffpin + "_1.wav"
127 ffpout2 = ffpin + "_2.wav"
128 ffpout3 = ffpin + ".m2v"
129 shutil.move(ffpin1, ffpout1)
130 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
131 exe = xvfb + ' -a ' + exe
132 recdblist.printutf8(exe)
133 commands.getoutput(exe.encode('utf-8'))
135 shutil.move(ffpin1, ffpout2)
136 shutil.move(ffpin2, ffpout3)
137 ffpout21=ffpout1.replace(".wav",".mp3")
138 ffpout22=ffpout2.replace(".wav",".mp3")
141 if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
146 ffpout21=ffpout1.replace(".wav",".aac")
147 ffpout22=ffpout2.replace(".wav",".aac")
148 tv2audio.wav2aac_nero(ffpout1, ffpout21)
149 tv2audio.wav2aac_nero(ffpout2, ffpout22)
151 tv2audio.wav2mp3_lame(ffpout1, ffpout21)
152 tv2audio.wav2mp3_lame(ffpout2, ffpout22)
157 def pentaaudiots2avi(pin, pout):
158 bontsdemux = configreader.getpath('bontsdemux')
159 bonpin = "Z:\\" + pin[1:]
160 xvfb = configreader.getpath('xvfb-run')
161 outf = os.path.splitext(pin)[0]
162 bonpout = "Z:\\" + outf[1:]
163 exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
164 exe = xvfb + ' -a ' + exe
165 recdblist.printutf8(exe)
166 commands.getoutput(exe.encode('utf-8'))
167 ffpin1 = pin.replace("ts", "wav")
168 ffpin2 = pin.replace("ts", "m2v")
169 exe = "ffmpeg -y -i \'" + ffpin1 + "\' -i \'" + ffpin2 + "\' -r 29.97 -vsync 200 -vcodec copy -acodec libmp3lame -async 200 -ab 128k -f avi \'" + pout + "\'"
170 recdblist.printutf8(exe)
171 commands.getoutput(exe.encode('utf-8'))