3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009-2010 Yukikaze
14 def ts2mkv(pin, pout, opt):
15 dir=os.path.split(pout)[0]
16 title=os.path.split(pout)[1]
17 title=os.path.splitext(title)[0]
18 tpraw=os.path.join(dir, title+".264")
19 tpmkv=os.path.join(dir, title+".mkv")
20 if os.path.isfile(pin) and os.path.getsize(pin)>10*1000:
21 tv2avi.ts2raw(pin, tpraw, opt)
23 if os.path.isfile(tpraw) and os.path.getsize(tpraw)>10*1000:
24 raw2mkv(tpraw, tpmkv, opt)
26 if os.path.exists(tpraw):
28 def raw2mkv(pin,pout,opt):#x264
29 dir=os.path.split(pout)[0]
30 title=os.path.split(pout)[1]
31 title=os.path.splitext(title)[0]
32 duration="--default-duration 0:30000/1001fps "
33 ffmpeg=configreader.getpath("ffmpeg")
36 if re.search("a",opt):
37 duration="--default-duration 0:24000/1001fps "
38 elif re.search("v",opt):
39 duration="--default-duration 0:24000/1001fps "
40 if re.search("d",opt):
42 duration="--default-duration 0:30000/1001fps "##ffmpegが24fpsに対応していないための措置
43 elif re.search("5",opt):
45 duration="--default-duration 0:30000/1001fps "##ffmpegが24fpsに対応していないための措置
46 exe = configreader.getpath("mkvmerge")
49 os.environ['LANG']="ja_JP.UTF-8"
51 wineexe=configreader.getpath("wine")
52 pincap=pin.replace(".264",".srt")
54 cap2ass=configreader.getpath("caption2ass")
57 pints=pin.replace(".264",".ts")
58 paac1=pin.replace(".264","_1.aac")
59 paac2=pin.replace(".264","_2.aac")
60 recdblist.printutf8(paac1)
61 if not os.path.exists(paac1):
62 paac1=pin.replace(".264","_1.mp3")
63 if not os.path.exists(paac2):
64 paac2=pin.replace(".264","_2.mp3")
65 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
66 e1=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --track-order 0:0,1:1,2:1"
67 e1s=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:1,2:1,3:0"
68 if os.path.isfile(cap2ass):
70 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
71 txt2=txt2+u"\n Cmd:"+e1s+u"\n"+execcomd(e1s)
73 txt2=txt2+u"\n Cmd:"+e1+u"\n"+execcomd(e1)
75 wineexe=configreader.getpath("wine")
76 pincap=pin.replace(".264",".srt")
78 cap2ass=configreader.getpath("caption2ass")
81 pints=pin.replace(".264",".ts")
82 paac1=pin.replace(".264","_1.aac")
83 paac2=pin.replace(".264","_2.aac")
84 recdblist.printutf8(paac1)
85 if not os.path.exists(paac1):
86 paac1=pin.replace(".264","_1.mp3")
87 if not os.path.exists(paac2):
88 paac2=pin.replace(".264","_2.mp3")
89 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
90 e1=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --track-order 0:0,1:1,2:1"
91 e1s=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:1,2:1,3:0"
92 if os.path.isfile(cap2ass):
94 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
95 txt2=txt2+u"\n Cmd:"+e1s+u"\n"+execcomd(e1s)
97 txt2=txt2+u"\n Cmd:"+e1+u"\n"+execcomd(e1)
99 wineexe=configreader.getpath("wine")
100 pincap=pin.replace(".264",".srt")
102 cap2ass=configreader.getpath("caption2ass")
105 pints=pin.replace(".264",".ts")
106 pinaac=pin.replace(".264",".aac")
107 e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
108 e1=ffmpeg+" -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\""
109 e2=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --track-order 0:0,1:0"
110 e2s=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:0,2:0"
111 if os.path.isfile(cap2ass):
114 if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
115 txt2=txt2+u"\n Cmd:"+e2s+"\n"+execcomd(e2s)
116 recdblist.printutf8(e2s)
118 txt2=txt2+u"\n Cmd:"+e2+"\n"+execcomd(e2)
119 recdblist.printutf8(e2)
120 recdblist.addlog(pout, txt, "mkvmerge-log1")
121 recdblist.addlog(pout, txt2, "mkvmerge-log2")
122 if status.getSettings_auto_del_tmp()==1:
123 if os.path.exists(pout):
124 if os.path.getsize(pout)>100*1000*1000:
128 cmdt=u"nice -n 17 "+cmd
130 txt=u"Cmd : "+cmd+"\n"
131 txt2=commands.getoutput(cmdt.encode('utf-8'))
132 txt=txt+unicode(txt2,"utf-8")+"\n"
136 def deltitle(path,title):
138 dp.append(os.path.join(path,title+".avi"))
139 dp.append(os.path.join(path,title+".264"))
140 dp.append(os.path.join(path,title+".120.avi"))
141 dp.append(os.path.join(path,title+".noodml.avi"))
142 dp.append(os.path.join(path,title+".aac"))
143 dp.append(os.path.join(path,title+".m2v"))
144 dp.append(os.path.join(path,title+"_1.aac"))
145 dp.append(os.path.join(path,title+"_2.aac"))
146 dp.append(os.path.join(path,title+"_1.mp3"))
147 dp.append(os.path.join(path,title+"_2.mp3"))
148 dp.append(os.path.join(path,title+".srt"))
149 if configreader.getenv("remove_ts")=="1":
150 dp.append(os.path.join(path,title+".ts"))
151 if os.path.exists(os.path.join(path,title+".ts"))and os.path.exists(os.path.join(path,title+".ts.b25")):
152 if os.path.getsize(os.path.join(path,title+".ts"))*10>os.path.getsize(os.path.join(path,title+".ts.b25")):
153 if os.path.getsize(os.path.join(path,title+".ts"))>1000*1000*100:
154 dp.append(os.path.join(path,title+".ts.b25"))
155 if os.path.exists(os.path.join(path,title+".mkv")):
156 if os.path.getsize(os.path.join(path,title+".mkv"))>1000*1000*10: