import time\r
import recdblist\r
import configreader\r
+import status\r
\r
def ts2mp4(pin, pout, opt):\r
dir=os.path.split(pout)[0]\r
title=os.path.split(pout)[1]\r
title=os.path.splitext(title)[0]\r
- tpavi=os.path.join(dir, title+".avi")\r
+ """tpavi=os.path.join(dir, title+".avi")\r
tv2avi.ts2avi(pin, tpavi, opt)\r
time.sleep(10)\r
if not os.path.exists(tpavi):\r
if os.path.exists(pin):\r
tpavi=pin\r
- avi2mp4(tpavi,pout,opt)\r
+ avi2mp4(tpavi,pout,opt)"""\r
+ tpraw=os.path.join(dir, title+".264")\r
+ tpmp4=os.path.join(dir, title+".mp4")\r
+ tv2avi.ts2raw(pin, tpraw, opt)\r
+ time.sleep(10)\r
+ raw2mp4(tpraw, tpmp4, opt)\r
def raw2mp4(pin,pout,opt):\r
dir=os.path.split(pout)[0]\r
title=os.path.split(pout)[1]\r
if not os.path.exists(paac2):\r
paac2=pin.replace(".264","_2.mp3")\r
e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""\r
- e1=exe +u" "+duration+" -add \""+pin+" -new \""+pout+"\""\r
- e1a1=exe +u" -add \""+paac1+" \""+pout+"\""\r
- e1a2=exe +u" -add \""+paac2+" \""+pout+"\""\r
- e1s=exe +u" -add \""+pincap+" \""+pout+"\""\r
+ e1=exe +u" "+duration+" -add \""+pin+"\" -new \""+pout+"\""\r
+ e1a1=exe +u" -add \""+paac1+"\" \""+pout+"\""\r
+ e1a2=exe +u" -add \""+paac2+"\" \""+pout+"\""\r
+ e1s=exe +u" -add \""+pincap+"\" \""+pout+"\""\r
+ if os.path.isfile(cap2ass):\r
+ txt=txt+execcomd(e0)\r
execmp4box(pin, pout, e1)\r
addmp4(paac1, pout, e1a1)\r
addmp4(paac2, pout, e1a2)\r
- if os.path.isfile(cap2ass):\r
- txt=txt+execcomd(e0)\r
if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):\r
addmp4(pincap, pout, e1s)\r
elif ispentaaudio==1:\r
if not os.path.exists(paac2):\r
paac2=pin.replace(".264","_2.mp3")\r
e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""\r
- e1=exe +u" "+duration+" -add \""+pin+" -new \""+pout+"\""\r
- e1a1=exe +u" -add \""+paac1+" \""+pout+"\""\r
- e1a2=exe +u" -add \""+paac2+" \""+pout+"\""\r
- e1s=exe +u" -add \""+pincap+" \""+pout+"\""\r
+ e1=exe +u" "+duration+" -add \""+pin+"\" -new \""+pout+"\""\r
+ e1a1=exe +u" -add \""+paac1+"\" \""+pout+"\""\r
+ e1a2=exe +u" -add \""+paac2+"\" \""+pout+"\""\r
+ e1s=exe +u" -add \""+pincap+"\" \""+pout+"\""\r
+ if os.path.isfile(cap2ass):\r
+ txt=txt+execcomd(e0)\r
execmp4box(pin, pout, e1)\r
addmp4(paac1, pout, e1a1)\r
addmp4(paac2, pout, e1a2)\r
- if os.path.isfile(cap2ass):\r
- txt=txt+execcomd(e0)\r
if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):\r
addmp4(pincap, pout, e1s)\r
else:\r
pinaac=pin.replace(".264",".aac")\r
e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""\r
e1="ffmpeg -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\""\r
- e2=exe +u" "+duration+" -add \""+pin+" -new \""+pout+"\""\r
- e2a=exe +u" -add \""+pinaac+" \""+pout+"\""\r
- e2s=exe +u" -add \""+pincap+" \""+pout+"\""\r
- execmp4box(pin, pout, e2)\r
- addmp4(pinaac, pout, e2a)\r
- addmp4(pincap, pout, e2s)\r
+ e2=exe +u" "+duration+" -add \""+pin+"\" -new \""+pout+"\""\r
+ e2a=exe +u" -add \""+pinaac+"\" \""+pout+"\""\r
+ e2s=exe +u" -add \""+pincap+"\" \""+pout+"\""\r
if os.path.isfile(cap2ass):\r
txt=txt+execcomd(e0)\r
+ txt=txt+execcomd(e1)\r
+ execmp4box(pin, pout, e2)\r
+ addmp4(pinaac, pout, e2a)\r
if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):\r
addmp4(pincap, pout, e2s)\r
recdblist.addlog(pout, txt, "mp4box-log")\r
if os.path.exists(tmpmp4):\r
os.remove(tmpmp4)\r
def execmp4box(pin,pout,cmd):\r
- ptin=os.path.join(os.path.dirname(pin),base64.b32encode(os.path.splitext(os.path.split(pin)[1])[0])+".264")\r
+ title=os.path.splitext(os.path.split(pin)[1])[0]\r
+ ptin=os.path.join(os.path.dirname(pin),base64.b16encode(title.encode('utf-8'))+".264")\r
+ recdblist.printutf8(ptin)\r
shutil.move(pin,ptin)\r
- ptout=os.path.join(os.path.dirname(pout),base64.b32encode(os.path.splitext(os.path.split(pout)[1])[0])+".mp4")\r
+ time.sleep(10)\r
+ ptout=os.path.join(os.path.dirname(pout),base64.b16encode(title.encode('utf-8'))+".mp4")\r
cmdn=string.replace(cmd,pin,ptin)\r
cmdn=string.replace(cmdn,pout,ptout)\r
+ recdblist.printutf8(cmdn)\r
txt=""\r
try:\r
txt=execcomd(cmdn)\r
txt=txt+ str(type(inst))+"\n"\r
txt=txt+str(inst)\r
recdblist.addlog(pin, txt, "MP4Box-log")\r
- time.sleep(3)\r
+ time.sleep(5)\r
+ shutil.move(ptin,pin)\r
shutil.move(ptout,pout)\r
+ time.sleep(5)\r
def addmp4(padd,pout,cmd):#without video\r
- ptadd=os.path.join(os.path.dirname(padd),base64.b32encode(os.path.splitext(os.path.split(padd)[1])[0])+"."+os.path.splitext(os.path.split(padd)[1])[1])\r
+ title=os.path.splitext(os.path.split(padd)[1])[0]\r
+ ext=os.path.splitext(os.path.split(padd)[1])[1]\r
+ ptadd=os.path.join(os.path.dirname(padd),base64.b16encode(title.encode('utf-8'))+ext)\r
+ ptoutb=os.path.join(os.path.dirname(pout),base64.b16encode(title.encode('utf-8'))+"_b.mp4")\r
+ ptout=os.path.join(os.path.dirname(pout),base64.b16encode(title.encode('utf-8'))+".mp4")\r
shutil.move(padd,ptadd)\r
- ptout=os.path.join(os.path.dirname(pout),base64.b32encode(os.path.splitext(os.path.split(pout)[1])[0])+".mp4")\r
+ if os.path.isfile(pout):\r
+ shutil.move(pout,ptoutb)\r
+ time.sleep(5)\r
cmdn=string.replace(cmd,padd,ptadd)\r
+ cmdn=string.replace(cmdn,u"-out \""+pout,u"-add \""+ptoutb+"\" -new \""+ptout)\r
+ cmdn=string.replace(cmdn,u"\""+pout,u"-add \""+ptoutb+"\" -new \""+ptout)\r
cmdn=string.replace(cmdn,pout,ptout)\r
+ recdblist.printutf8(cmdn)\r
txt=""\r
try:\r
txt=execcomd(cmdn)\r
txt= "error occures in addmp4\n"\r
txt=txt+ str(type(inst))+"\n"\r
txt=txt+str(inst)\r
- recdblist.addlog(pin, txt, "MP4Box-log-add")\r
- time.sleep(3)\r
+ recdblist.addlog(pout, txt, "MP4Box-log-add")\r
+ time.sleep(5)\r
+ os.remove(ptoutb)\r
+ shutil.move(ptadd,padd)\r
shutil.move(ptout,pout)\r
+ time.sleep(5)\r
def execcomd(cmd):\r
txt=""\r
try:\r