3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
15 def ts2mp4(pin, pout, opt):
16 dir=os.path.split(pout)[0]
17 title=os.path.split(pout)[1]
18 title=os.path.splitext(title)[0]
19 tpavi=os.path.join(dir, title+".avi")
20 tv2avi.ts2avi(pin, tpavi, opt)
22 if not os.path.exists(tpavi):
23 if os.path.exists(pin):
25 avi2mp4(tpavi,pout,opt)
26 def avi2mp4(pin,pout,opt):
27 if re.search(u"v", opt):
29 exe = configreader.getpath(u"MP4Box")
30 dir=os.path.split(pin)[0]
31 title=os.path.split(pin)[1]
32 title=os.path.splitext(title)[0]
33 audiopath=os.path.join(dir,title+u"_audio.raw")
34 videopath=os.path.join(dir,title+u"_video.h264")
36 exes.append(exe+u" -aviraw audio \'"+pin+u"\'")
37 exes.append(exe+u" -aviraw video \'"+pin+u"\'")
38 exes.append(exe+u" -new -fps 29.97 -add \'"+videopath+u"\'#video -add \'"+audiopath+u"\'#audio \'"+pout+u"\'")
41 wineexe=configreader.getpath("wine")
42 cfr2tc=configreader.getpath("cfr2tc")
43 dtsedit=configreader.getpath("DtsEdit")
44 pin120=pin.replace(".avi",".120.avi")
45 pints=pin.replace(".avi",".ts")
46 pmp4=pin.replace(".avi",".tmp.mp4")
47 pintimecode=pin.replace(".avi",".timecode.txt")
48 pinaac=pin.replace(".avi",".aac")
50 evfr.append("ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'")
51 evfr.append(wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' 'Z:\\"+pintimecode+u"' 2")
52 evfr.append(exe+u" -aviraw video \'"+pin120+u"\'")
53 videotpath=os.path.join(dir,title+u".120_video.h264")
54 evfr.append(exe+u" -fps 29.97 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'")
55 #evfr.append(exe+u" -add \'"+pinaac+"\' \'"+pmp4+"\'")
56 evfr.append(wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'")
59 logo=pin.replace(u".avi",u".log")
60 os.environ['LANG']="ja_JP.UTF-8"
64 recdblist.printutf8(e)
67 txt=txt+unicode(commands.getoutput(e.encode('utf-8')),'utf-8')
70 txt = "\n####MP4Box-log####\n"+txt
72 f.write(txt.encode('utf-8'))
75 if os.path.exists(pout):
76 if os.path.exists(audiopath):
78 if os.path.exists(videopath):
80 def mkv2mp4(pin,pout):
81 exeb = configreader.getpath(u"mkvextract")
82 exe = configreader.getpath(u"MP4Box")
83 dir=os.path.split(pin)[0]
84 title=os.path.split(pin)[1]
85 title=os.path.splitext(title)[0]
86 audiopath=os.path.join(dir,title+u"_audio.mp3")
87 if not os.path.exists(audiopath):
88 if os.path.exists(os.path.join(dir,title+u"_audio.raw")):
89 audiopath=os.path.join(dir,title+u"_audio.raw")
90 if os.path.exists(os.path.join(dir,title+u"_audio.aac")):
91 audiopath=os.path.join(dir,title+u"_audio.aac")
92 videopath=os.path.join(dir,title+u"_video.h264")
93 #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
94 exe0=exeb+u" tracks \'"+pin+u"\' 1:\'"+videopath+u"\' 2:\'"+audiopath+u"\'"
95 exe1=exe+u" -aviraw audio \'"+pin+u"\'"
96 exe2=exe+u" -aviraw video \'"+pin+u"\'"
97 exefin=exe+u" -new -fps 29.970030 -add \'"+videopath+u"\'#video -add \'"+audiopath+u"\'#audio \'"+pout+u"\'"
98 logo=pin.replace(".avi",".log")
99 os.environ['LANG']="ja_JP.UTF-8"
100 txt= exe0+"\n"+exe1+"\n"+exe2+"\n"+exefin+"\n"
101 txt = txt+unicode(commands.getoutput(exe0.encode('utf-8')),'utf-8')
102 txt = txt+unicode(commands.getoutput(exe1.encode('utf-8')),'utf-8')
103 txt = txt+unicode(commands.getoutput(exe2.encode('utf-8')),'utf-8')
104 txt = txt+unicode(commands.getoutput(exefin.encode('utf-8')),'utf-8')
107 txt = "\n####MKV2MP4-log####\n"+txt
109 f.write(txt.encode('utf-8'))
112 if os.path.exists(pout):
113 if os.path.exists(audiopath):
115 if os.path.exists(videopath):