title=os.path.splitext(title)[0]\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
+ if os.path.isfile(pin) and os.path.getsize(pin)>10*1000:\r
+ tv2avi.ts2raw(pin, tpraw, opt)\r
+ time.sleep(10)\r
+ if os.path.isfile(tpraw) and os.path.getsize(tpraw)>10*1000:\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 isdualaac==1:\r
wineexe=configreader.getpath("wine")\r
pincap=pin.replace(".264",".srt")\r
- cap2ass=configreader.getpath("Caption2Ass")\r
+ cap2ass=configreader.getpath("caption2ass")\r
pints=pin.replace(".264",".ts")\r
paac1=pin.replace(".264","_1.aac")\r
paac2=pin.replace(".264","_2.aac")\r
elif ispentaaudio==1:\r
wineexe=configreader.getpath("wine")\r
pincap=pin.replace(".264",".srt")\r
- cap2ass=configreader.getpath("Caption2Ass")\r
+ cap2ass=configreader.getpath("caption2ass")\r
pints=pin.replace(".264",".ts")\r
paac1=pin.replace(".264","_1.aac")\r
paac2=pin.replace(".264","_2.aac")\r
else:\r
wineexe=configreader.getpath("wine")\r
pincap=pin.replace(".264",".srt")\r
- cap2ass=configreader.getpath("Caption2Ass")\r
+ cap2ass=configreader.getpath("caption2ass")\r
pints=pin.replace(".264",".ts")\r
pinaac=pin.replace(".264",".aac")\r
e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""\r
if os.path.exists(pout):\r
if os.path.getsize(pout)>100*1000*1000:\r
deltitle(dir,title)\r
-def avi2mp4(pin,pout,opt):\r
- isvfr=0\r
- if re.search(u"v", opt):\r
- isvfr=1\r
- exe = configreader.getpath(u"MP4Box")\r
- dir=os.path.split(pin)[0]\r
- title=os.path.split(pin)[1]\r
- title=os.path.splitext(title)[0]\r
- etitle=base64.b16encode(title.encode('utf-8'))\r
- audiopath=os.path.join(dir,etitle+u"_audio.raw")\r
- videopath=os.path.join(dir,etitle+u"_video.264")\r
- exes=[]\r
- os.environ['LANG']="ja_JP.UTF-8"\r
- txt=""\r
- if isvfr==1:\r
- wineexe=configreader.getpath("wine")\r
- cfr2tc=configreader.getpath("cfr2tc")\r
- dtsedit=configreader.getpath("DtsEdit")\r
- caption2ass=configreader.getpath("Caption2Ass")\r
- pin120=os.path.join(dir,etitle+u".120.avi")\r
- pints=os.path.join(dir,title+u".ts")\r
- pmp4=os.path.join(dir,etitle+u".tmp.mp4")\r
- pintimecode=os.path.join(dir,etitle+u".timecode.txt")\r
- pinaac=os.path.join(dir,etitle+u".aac")\r
- pincat=os.path.join(dir,etitle+u".srt")\r
- evfr0=ffmpeg+u" -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"\r
- evfr1=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' 'Z:\\"+pintimecode+u"' 2"\r
- evfr2=exe+u" -aviraw video \'"+pin120+u"\'"\r
- videotpath=os.path.join(dir,etitle+u".120_video.h264")\r
- evfr3=exe+u" -fps 29.970030 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"\r
- evfr4=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'"\r
- try:\r
- recdblist.printutf8(evfr0)\r
- txt=txt+evfr0+"\n"\r
- txt=txt+unicode(commands.getoutput(evfr0.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- recdblist.printutf8(evfr1)\r
- txt=txt+evfr1+"\n"\r
- txt=txt+unicode(commands.getoutput(evfr1.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- if not os.path.exists(pin120):\r
- evfr2=exe+u" -aviraw video \'"+pin+u"\'"\r
- videotpath=os.path.join(dir,etitle+u"_video.h264")\r
- evfr3=exe+u" -fps 29.970030 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"\r
- recdblist.printutf8(evfr2)\r
- txt=txt+evfr2+"\n"\r
- txt=txt+unicode(commands.getoutput(evfr2.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- recdblist.printutf8(evfr3)\r
- txt=txt+evfr3+"\n"\r
- txt=txt+unicode(commands.getoutput(evfr3.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- recdblist.printutf8(evfr4)\r
- txt=txt+evfr4+"\n"\r
- txt=txt+unicode(commands.getoutput(evfr4.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- if (not os.path.exists(pin.replace(".avi",".120.avi"))and (not os.path.exists(pout))):\r
- txt=txt+"CFR2TC error. maybe avi file is over 1GB.(ODML error would have happened.)"\r
- ptmp=pin.replace(".avi",".noodml.avi")\r
- e="mencoder -noodml -forceidx -oac copy -ovc copy -o \'"+ptmp+"\'"+" \'"+pin+"\'"\r
- ex="nice -n 17 "+e\r
- e2=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+ptmp+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"\r
- ex2="nice -n 17 "+e2\r
- e3=exe+u" -aviraw video \'"+pin120+u"\'"\r
- ex3="nice -n 17 "+e3\r
- e4=exe+u" -fps 29.97 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"\r
- ex4="nice -n 17 "+e4\r
- e5=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'"\r
- ex5="nice -n 17 "+e5\r
- recdblist.printutf8(e)\r
- txt=txt+e+"\n"\r
- try:\r
- cmdt=unicode(commands.getoutput(ex.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- cmdt=unicode(commands.getoutput(ex2.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- if os.path.exists(pin120):\r
- cmdt=unicode(commands.getoutput(ex3.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- cmdt=unicode(commands.getoutput(ex4.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- cmdt=unicode(commands.getoutput(ex5.encode('utf-8')),'utf-8')\r
- except:\r
- ""\r
- try:\r
- os.remove(ptmp)\r
- except:\r
- ""\r
- txt=txt+cmdt+"\n"\r
- else:\r
- try:\r
- shutil.move(pin,os.path.join(dir,etitle+".avi"))\r
- except:\r
- ""\r
- if os.path.exists(os.path.join(dir,etitle+".avi")):\r
- e0=exe+u" -aviraw audio \'"+os.path.join(dir,etitle+".avi")+u"\'"\r
- e1=exe+u" -aviraw video \'"+os.path.join(dir,etitle+".avi")+u"\'"\r
- os.system(e0)\r
- os.system(e1)\r
- if not os.path.exists(audiopath):\r
- if os.path.exists(os.path.join(dir,etitle+u"_audio.mp3")):\r
- audiopath=os.path.join(dir,etitle+u"_audio.mp3")\r
- elif os.path.exists(os.path.join(dir,etitle+u"_audio.aac")):\r
- audiopath=os.path.join(dir,etitle+u"_audio.aac")\r
- else:\r
- shutil.move(audiopath,os.path.join(dir,etitle+u"_audio.aac"))\r
- audiopath=os.path.join(dir,etitle+u"_audio.aac")\r
- ptmp=os.path.exists(os.path.join(dir,etitle+u".mp4"))\r
- e2=exe+u" -fps 29.970030 -add \'"+videopath+u"\' -add \'"+audiopath+u"\' -new \'"+ptmp+u"\'"\r
- os.system(e2)\r
- shutil.move(ptmp,pout)\r
- recdblist.addlog(pin,txt,"MP4Box-log")\r
- time.sleep(10)\r
- delpath=[]\r
- delpath.append(pin.replace(u".avi",u".120.avi"))\r
- delpath.append(pin.replace(u".avi",u".sa.avi"))\r
- delpath.append(pin.replace(u".avi",u".m2v"))\r
- delpath.append(pin.replace(u".avi",u"_1.aac"))\r
- delpath.append(pin.replace(u".avi",u"_2.aac"))\r
- delpath.append(pin.replace(u".avi",u"_1.mp3"))\r
- delpath.append(pin.replace(u".avi",u"_2.mp3"))\r
- delpath.append(pin.replace(u".avi",u".ts"))\r
- delpath.append(pin.replace(u".avi",u".aac"))\r
- delpath.append(pin.replace(u".avi",u".m2v"))\r
- delpath.append(pin.replace(u".avi",u".120_video.264"))\r
- delpath.append(pin.replace(u".avi",u".ts.b25"))\r
- if os.path.exists(pout):\r
- if os.path.exists(audiopath):\r
- os.remove(audiopath)\r
- if os.path.exists(videopath):\r
- os.remove(videopath)\r
- """\r
- for dp in delpath:\r
- try:\r
- os.remove(dp)\r
- except:\r
- ""\r
- """\r
def mkv2mp4(pin,pout):\r
exeb = configreader.getpath(u"mkvextract")\r
- exe = configreader.getpath(u"MP4Box")\r
- dtsedit=configreader.getpath("DtsEdit")\r
+ exe = configreader.getpath(u"mp4Box")\r
+ #dtsedit=configreader.getpath("DtsEdit")\r
wineexe=configreader.getpath("wine")\r
dir=os.path.split(pin)[0]\r
title=os.path.split(pin)[1]\r
recdblist.addlog(pin, txt, "MKV2MP4-log")\r
txt = "\n####MKV2MP4-log####\n"+txt\r
time.sleep(10)\r
- if os.path.exists(pout):\r
- if os.path.exists(audiopath):\r
- os.remove(audiopath)\r
- if os.path.exists(videopath):\r
- os.remove(videopath)\r
- if os.path.exists(timecodepath):\r
- os.remove(timecodepath)\r
- if os.path.exists(tmpmp4):\r
- os.remove(tmpmp4)\r
+ if status.getSettings_auto_del_tmp()==1:\r
+ if os.path.exists(pout):\r
+ if os.path.getsize(pout)>100*1000*1000:\r
+ deltitle(dir,title)\r
def execmp4box(pin,pout,cmd):\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
dp.append(os.path.join(path,title+"_1.mp3"))\r
dp.append(os.path.join(path,title+"_2.mp3"))\r
dp.append(os.path.join(path,title+".srt"))\r
+ if configreader.getenv("remove_ts")=="1":\r
+ dp.append(os.path.join(path,title+".ts"))\r
if os.path.exists(os.path.join(path,title+".ts"))and os.path.exists(os.path.join(path,title+".ts.b25")):\r
if os.path.getsize(os.path.join(path,title+".ts"))*10>os.path.getsize(os.path.join(path,title+".ts.b25")):\r
if os.path.getsize(os.path.join(path,title+".ts"))>1000*1000*100:\r