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 def avi2mp4(pin,pout):
24 exe = configreader.getpath("MP4Box")
25 dir=os.path.split(pin)[0]
26 title=os.path.split(pin)[1]
27 title=os.path.splitext(title)[0]
28 audiopath=os.path.join(dir,title+"_audio.mp3")
29 videopath=os.path.join(dir,title+"_video.h264")
30 #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
31 exe1=exe+" -aviraw audio \'"+pin+"\'"
32 exe2=exe+" -aviraw video \'"+pin+"\'"
33 exefin=exe+" -new -fps 29.97 -add \'"+videopath+"\'#video -add \'"+audiopath+"\'#audio \'"+pout+"\'"
34 logo=pin.replace(".avi",".log")
35 os.environ['LANG']="ja_JP.UTF-8"
36 txt= exe1+"\n"+exe2+"\n"+exefin+"\n"
37 txt = txt+commands.getoutput(exe1)
38 txt = txt+commands.getoutput(exe2)
39 txt = txt+commands.getoutput(exefin)
42 txt = "\n####MP4Box-log####\n"+txt
48 if os.path.exists(pout):
49 if os.path.exists(audiopath):
51 if os.path.exists(videopath):
53 def mkv2mp4(pin,pout):
54 exeb = configreader.getpath("mkvextract")
55 exe = configreader.getpath("MP4Box")
56 dir=os.path.split(pin)[0]
57 title=os.path.split(pin)[1]
58 title=os.path.splitext(title)[0]
59 audiopath=os.path.join(dir,title+"_audio.mp3")
60 if not os.path.exists(audiopath):
61 if os.path.exists(os.path.join(dir,title+"_audio.raw")):
62 audiopath=os.path.join(dir,title+"_audio.raw")
63 if os.path.exists(os.path.join(dir,title+"_audio.aac")):
64 audiopath=os.path.join(dir,title+"_audio.aac")
65 videopath=os.path.join(dir,title+"_video.h264")
66 #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
67 exe0=exeb+" tracks \'"+pin+"\' 1:\'"+videopath+"\' 2:\'"+audiopath+"\'"
68 exe1=exe+" -aviraw audio \'"+pin+"\'"
69 exe2=exe+" -aviraw video \'"+pin+"\'"
70 exefin=exe+" -new -fps 29.97 -add \'"+videopath+"\'#video -add \'"+audiopath+"\'#audio \'"+pout+"\'"
71 logo=pin.replace(".avi",".log")
72 os.environ['LANG']="ja_JP.UTF-8"
73 txt= exe0+"\n"+exe1+"\n"+exe2+"\n"+exefin+"\n"
74 txt = txt+commands.getoutput(exe0)
75 txt = txt+commands.getoutput(exe1)
76 txt = txt+commands.getoutput(exe2)
77 txt = txt+commands.getoutput(exefin)
80 txt = "\n####MKV2MP4-log####\n"+txt
86 if os.path.exists(pout):
87 if os.path.exists(audiopath):
89 if os.path.exists(videopath):