3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
12 def ts2mp4(pin, pout, opt):
13 dir=os.path.split(pout)[0]
14 title=os.path.split(pout)[1]
15 title=os.path.splitext(title)[0]
16 tpavi=os.path.join(dir, title+".avi")
17 tv2avi.ts2avi(pin, tpavi, opt)
19 if not os.path.exists(tpavi):
20 if os.path.exists(pin):
23 if re.search("v", opt):
25 avi2mp4(tpavi,pout,isvfr)
26 def avi2mp4(pin,pout,isvfr):
27 exe = configreader.getpath(u"MP4Box")
28 dir=os.path.split(pin)[0]
29 title=os.path.split(pin)[1]
30 title=os.path.splitext(title)[0]
31 audiopath=os.path.join(dir,title+u"_audio.mp3")
32 videopath=os.path.join(dir,title+u"_video.h264")
35 #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
36 exe1=exe+u" -aviraw audio \'"+pin+u"\'"
37 exe2=exe+u" -aviraw video \'"+pin+u"\'"
38 exefin=exe+u" -new -fps 29.97 -add \'"+videopath+u"\'#video -add \'"+audiopath+u"\'#audio \'"+pout+u"\'"
39 logo=pin.replace(u".avi",u".log")
40 os.environ['LANG']="ja_JP.UTF-8"
41 txt= exe1+u"\n"+exe2+u"\n"+exefin+u"\n"
42 txt = txt+unicode(commands.getoutput(exe1.encode('utf-8')),'utf-8')
43 txt = txt+unicode(commands.getoutput(exe2.encode('utf-8')),'utf-8')
44 txt = txt+unicode(commands.getoutput(exefin.encode('utf-8')),'utf-8')
47 txt = "\n####MP4Box-log####\n"+txt
49 f.write(txt.encode('utf-8'))
52 if os.path.exists(pout):
53 if os.path.exists(audiopath):
55 if os.path.exists(videopath):
57 def mkv2mp4(pin,pout):
58 exeb = configreader.getpath(u"mkvextract")
59 exe = configreader.getpath(u"MP4Box")
60 dir=os.path.split(pin)[0]
61 title=os.path.split(pin)[1]
62 title=os.path.splitext(title)[0]
63 audiopath=os.path.join(dir,title+u"_audio.mp3")
64 if not os.path.exists(audiopath):
65 if os.path.exists(os.path.join(dir,title+u"_audio.raw")):
66 audiopath=os.path.join(dir,title+u"_audio.raw")
67 if os.path.exists(os.path.join(dir,title+u"_audio.aac")):
68 audiopath=os.path.join(dir,title+u"_audio.aac")
69 videopath=os.path.join(dir,title+u"_video.h264")
70 #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
71 exe0=exeb+u" tracks \'"+pin+u"\' 1:\'"+videopath+u"\' 2:\'"+audiopath+u"\'"
72 exe1=exe+u" -aviraw audio \'"+pin+u"\'"
73 exe2=exe+u" -aviraw video \'"+pin+u"\'"
74 exefin=exe+u" -new -fps 29.970030 -add \'"+videopath+u"\'#video -add \'"+audiopath+u"\'#audio \'"+pout+u"\'"
75 logo=pin.replace(".avi",".log")
76 os.environ['LANG']="ja_JP.UTF-8"
77 txt= exe0+"\n"+exe1+"\n"+exe2+"\n"+exefin+"\n"
78 txt = txt+unicode(commands.getoutput(exe0.encode('utf-8')),'utf-8')
79 txt = txt+unicode(commands.getoutput(exe1.encode('utf-8')),'utf-8')
80 txt = txt+unicode(commands.getoutput(exe2.encode('utf-8')),'utf-8')
81 txt = txt+unicode(commands.getoutput(exefin.encode('utf-8')),'utf-8')
84 txt = "\n####MKV2MP4-log####\n"+txt
86 f.write(txt.encode('utf-8'))
89 if os.path.exists(pout):
90 if os.path.exists(audiopath):
92 if os.path.exists(videopath):