-import os
-#!/usr/bin/python
-# coding: UTF-8
-# Rec10 TS Recording Tools
-# Copyright (C) 2009 Yukikaze
-import commands
-import tv2avi
-import os.path
-import time
-import re
-import recdblist
-import configreader
-def ts2mkv(pin, pout, opt):
- dir=os.path.split(pout)[0]
- title=os.path.split(pout)[1]
- title=os.path.splitext(title)[0]
- tpavi=os.path.join(dir,title+".avi")
- tpmkv=os.path.join(dir, title+".mkv")
- tv2avi.ts2avi(pin, tpavi, opt)
- time.sleep(10)
- avi2mkv(tpavi,tpmkv,opt)
-def avi2mkv(pin,pout,opt):
- isvfr=0
- if re.search("v", opt):
- isvfr=1
- exe = configreader.getpath("mkvmerge")
- exes=[]
- txt=""
- os.environ['LANG']="ja_JP.UTF-8"
- if isvfr==1:
- wineexe=configreader.getpath("wine")
- cfr2tc=configreader.getpath("cfr2tc")
- pin120=pin.replace(".avi",".120.avi")
- pints=pin.replace(".avi",".ts")
- pintimecode=pin.replace(".avi",".timecode.txt")
- pinaac=pin.replace(".avi",".aac")
- exes.append("ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'")
- exes.append(wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2")
- exes.append(exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
- #exes.append(exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
- #exes.append(doexe = exe + u" -o '" + pout + u"' --cues 0:all --forced-track 0:no --default-duration 0:120000/1001fps -d 0 -A -S '" + pin + u"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
- for e in exes:
- ex= "nice -n 17 "+e
- recdblist.printutf8(e)
- txt=txt+e+"\n"
- cmdt=""
- try:
- cmdt=unicode(commands.getoutput(ex.encode('utf-8')),'utf-8')
- except:
- ""
- txt=txt+cmdt+"\n"
- if (not os.path.exists(pin.replace(".avi",".120.avi"))and (not os.path.exists(pout))):
- txt=txt+"CFR2TC error. maybe avi file is over 1GB.(ODML error would have happend.)"
- ptmp=pin.replace(".avi",".noodml.avi")
- e="mencoder -noodml -forceidx -oac copy -ovc copy -o \'"+ptmp+"\'"+" \'"+pin+"\'"
- ex="nice -n 17 "+e
- e2=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+ptmp+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
- ex2="nice -n 17 "+e2
- e3=exe +" -o '"+pout+u"' --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
- recdblist.printutf8(e)
- txt=txt+e+"\n"
- try:
- cmdt=unicode(commands.getoutput(ex.encode('utf-8')),'utf-8')
- cmdt=cmdt+unicode(commands.getoutput(ex2.encode('utf-8')),'utf-8')
- cmdt=cmdt+unicode(commands.getoutput(e3.encode('utf-8')),'utf-8')
- os.remove(ptmp)
- except:
- ""
- txt=txt+cmdt+"\n"
- else:
- exes.append(exe + u" -o '" + pout + u"' --forced-track 0:no --forced-track 1:no -a 1 -d 0 -S '" + pin + u"' --track-order 0:0,0:1")
- for e in exes:
- ex= "nice -n 17 "+e
- recdblist.printutf8(e)
- txt=txt+e+"\n"
- cmdt=""
- try:
- cmdt=unicode(commands.getoutput(ex.encode('utf-8')),'utf-8')
- except:
- ""
- txt=txt+cmdt+"\n"
- logo=pout.replace(".mkv",".log")
- """if (isvfr==1 and (not os.path.exists(pin.replace(".avi",".120.avi"))) and (not os.path.exists(pout))):
- exes=[]
- exes.append(exe + u" -o '" + pout + u"' --cues 0:all --forced-track 0:no --default-duration 0:120000/1001fps -d 0 -A -S '" + pin + u"' --sync 0:0 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0")
- txt=txt+"120fps cfr exection\n"
- for e2 in exes:
- recdblist.printutf8(e2)
- try:
- txt=txt+unicode(commands.getoutput(e2.encode('utf-8')),'utf-8')
- except:
- ""
- """
- txt = "\n####mkvmerge-log####\n"+txt
- f=open(logo,'a')
- f.write(txt.encode('utf-8'))
- f.close()
\ No newline at end of file
+#!/usr/bin/python\r
+# coding: UTF-8\r
+# Rec10 TS Recording Tools\r
+# Copyright (C) 2009-2010 Yukikaze\r
+import os\r
+import os.path\r
+import tv2mp4\r
+import configreader\r
+import subprocess\r
+import auto_process\r
+def ts2mkv(pin, pout, opt):\r
+ tpout=pout.replace(".mkv",".mp4")\r
+ tv2mp4.ts2mp4(pin, tpout, opt)\r
+ mp42mkv(pout, tpout)\r
+ if os.path.exists(pout) and os.path.getsize(pout)>os.path.getsize(tpout)*0.9:\r
+ os.remove(tpout)\r
+def mp42mkv(pmkv,pmp4):\r
+ exe = configreader.getConfPath("mkvmerge")\r
+ e1=exe +" -o \""+pmkv+u"\" \""+pmp4+"\""\r
+ p=subprocess.Popen(e1,shell=True)\r
+ os.waitpid(p.pid, 0)\r