From: gn64_jp Date: Thu, 4 Mar 2010 01:29:49 +0000 (+0000) Subject: implement new mp4 encoding(beta). X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=commitdiff_plain;h=4fc22a9c2a61591faecff30cee4169212d9c5777 implement new mp4 encoding(beta). git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@452 4e526526-5e11-4fc0-8910-f8fd03428081 --- diff --git a/rec10/trunk/src/timerec.py b/rec10/trunk/src/timerec.py index 265cf24..1ef4cee 100644 --- a/rec10/trunk/src/timerec.py +++ b/rec10/trunk/src/timerec.py @@ -531,9 +531,23 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt): if not os.path.exists(paac2) and not os.path.exists(pmp32): tv2avi.pentaaudio2sep(os.path.join(recpath, title+".ts")) time.sleep(3) - pout = recpath + "/" + title + ".mkv" + makeMP4=0 + try: + if configreader.getenv("make_mp4")==1: + makeMP4=1 + except: + "" + if re.search("m", opt): + makeMP4=0 + if re.search("4", opt): + makeMP4=1 recdblist.printutf8(pin) - tv2mkv.ts2mkv(pin, pout, opt) + if makeMP4==1: + pout = recpath + "/" + title + ".mp4" + tv2mp4.ts2mp4(pin, pout, opt) + else: + pout = recpath + "/" + title + ".mkv" + tv2mkv.ts2mkv(pin, pout, opt) recdb.del_reckey(typetxting, title, chtxt, btime) time.sleep(10) if re.search("E", opt): diff --git a/rec10/trunk/src/tv2mp4.py b/rec10/trunk/src/tv2mp4.py index b9e705c..641b352 100644 --- a/rec10/trunk/src/tv2mp4.py +++ b/rec10/trunk/src/tv2mp4.py @@ -13,18 +13,24 @@ import base64 import time import recdblist import configreader +import status def ts2mp4(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") + """tpavi=os.path.join(dir, title+".avi") tv2avi.ts2avi(pin, tpavi, opt) time.sleep(10) if not os.path.exists(tpavi): if os.path.exists(pin): tpavi=pin - avi2mp4(tpavi,pout,opt) + avi2mp4(tpavi,pout,opt)""" + tpraw=os.path.join(dir, title+".264") + tpmp4=os.path.join(dir, title+".mp4") + tv2avi.ts2raw(pin, tpraw, opt) + time.sleep(10) + raw2mp4(tpraw, tpmp4, opt) def raw2mp4(pin,pout,opt): dir=os.path.split(pout)[0] title=os.path.split(pout)[1] @@ -58,15 +64,15 @@ def raw2mp4(pin,pout,opt): if not os.path.exists(paac2): paac2=pin.replace(".264","_2.mp3") e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\"" - e1=exe +u" "+duration+" -add \""+pin+" -new \""+pout+"\"" - e1a1=exe +u" -add \""+paac1+" \""+pout+"\"" - e1a2=exe +u" -add \""+paac2+" \""+pout+"\"" - e1s=exe +u" -add \""+pincap+" \""+pout+"\"" + e1=exe +u" "+duration+" -add \""+pin+"\" -new \""+pout+"\"" + e1a1=exe +u" -add \""+paac1+"\" \""+pout+"\"" + e1a2=exe +u" -add \""+paac2+"\" \""+pout+"\"" + e1s=exe +u" -add \""+pincap+"\" \""+pout+"\"" + if os.path.isfile(cap2ass): + txt=txt+execcomd(e0) execmp4box(pin, pout, e1) addmp4(paac1, pout, e1a1) addmp4(paac2, pout, e1a2) - if os.path.isfile(cap2ass): - txt=txt+execcomd(e0) if os.path.exists(pincap) and (os.path.getsize(pincap)>1000): addmp4(pincap, pout, e1s) elif ispentaaudio==1: @@ -82,15 +88,15 @@ def raw2mp4(pin,pout,opt): if not os.path.exists(paac2): paac2=pin.replace(".264","_2.mp3") e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\"" - e1=exe +u" "+duration+" -add \""+pin+" -new \""+pout+"\"" - e1a1=exe +u" -add \""+paac1+" \""+pout+"\"" - e1a2=exe +u" -add \""+paac2+" \""+pout+"\"" - e1s=exe +u" -add \""+pincap+" \""+pout+"\"" + e1=exe +u" "+duration+" -add \""+pin+"\" -new \""+pout+"\"" + e1a1=exe +u" -add \""+paac1+"\" \""+pout+"\"" + e1a2=exe +u" -add \""+paac2+"\" \""+pout+"\"" + e1s=exe +u" -add \""+pincap+"\" \""+pout+"\"" + if os.path.isfile(cap2ass): + txt=txt+execcomd(e0) execmp4box(pin, pout, e1) addmp4(paac1, pout, e1a1) addmp4(paac2, pout, e1a2) - if os.path.isfile(cap2ass): - txt=txt+execcomd(e0) if os.path.exists(pincap) and (os.path.getsize(pincap)>1000): addmp4(pincap, pout, e1s) else: @@ -101,14 +107,14 @@ def raw2mp4(pin,pout,opt): pinaac=pin.replace(".264",".aac") e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\"" e1="ffmpeg -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\"" - e2=exe +u" "+duration+" -add \""+pin+" -new \""+pout+"\"" - e2a=exe +u" -add \""+pinaac+" \""+pout+"\"" - e2s=exe +u" -add \""+pincap+" \""+pout+"\"" - execmp4box(pin, pout, e2) - addmp4(pinaac, pout, e2a) - addmp4(pincap, pout, e2s) + e2=exe +u" "+duration+" -add \""+pin+"\" -new \""+pout+"\"" + e2a=exe +u" -add \""+pinaac+"\" \""+pout+"\"" + e2s=exe +u" -add \""+pincap+"\" \""+pout+"\"" if os.path.isfile(cap2ass): txt=txt+execcomd(e0) + txt=txt+execcomd(e1) + execmp4box(pin, pout, e2) + addmp4(pinaac, pout, e2a) if os.path.exists(pincap) and (os.path.getsize(pincap)>1000): addmp4(pincap, pout, e2s) recdblist.addlog(pout, txt, "mp4box-log") @@ -310,11 +316,15 @@ def mkv2mp4(pin,pout): if os.path.exists(tmpmp4): os.remove(tmpmp4) def execmp4box(pin,pout,cmd): - ptin=os.path.join(os.path.dirname(pin),base64.b32encode(os.path.splitext(os.path.split(pin)[1])[0])+".264") + title=os.path.splitext(os.path.split(pin)[1])[0] + ptin=os.path.join(os.path.dirname(pin),base64.b16encode(title.encode('utf-8'))+".264") + recdblist.printutf8(ptin) shutil.move(pin,ptin) - ptout=os.path.join(os.path.dirname(pout),base64.b32encode(os.path.splitext(os.path.split(pout)[1])[0])+".mp4") + time.sleep(10) + ptout=os.path.join(os.path.dirname(pout),base64.b16encode(title.encode('utf-8'))+".mp4") cmdn=string.replace(cmd,pin,ptin) cmdn=string.replace(cmdn,pout,ptout) + recdblist.printutf8(cmdn) txt="" try: txt=execcomd(cmdn) @@ -323,14 +333,25 @@ def execmp4box(pin,pout,cmd): txt=txt+ str(type(inst))+"\n" txt=txt+str(inst) recdblist.addlog(pin, txt, "MP4Box-log") - time.sleep(3) + time.sleep(5) + shutil.move(ptin,pin) shutil.move(ptout,pout) + time.sleep(5) def addmp4(padd,pout,cmd):#without video - 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]) + title=os.path.splitext(os.path.split(padd)[1])[0] + ext=os.path.splitext(os.path.split(padd)[1])[1] + ptadd=os.path.join(os.path.dirname(padd),base64.b16encode(title.encode('utf-8'))+ext) + ptoutb=os.path.join(os.path.dirname(pout),base64.b16encode(title.encode('utf-8'))+"_b.mp4") + ptout=os.path.join(os.path.dirname(pout),base64.b16encode(title.encode('utf-8'))+".mp4") shutil.move(padd,ptadd) - ptout=os.path.join(os.path.dirname(pout),base64.b32encode(os.path.splitext(os.path.split(pout)[1])[0])+".mp4") + if os.path.isfile(pout): + shutil.move(pout,ptoutb) + time.sleep(5) cmdn=string.replace(cmd,padd,ptadd) + cmdn=string.replace(cmdn,u"-out \""+pout,u"-add \""+ptoutb+"\" -new \""+ptout) + cmdn=string.replace(cmdn,u"\""+pout,u"-add \""+ptoutb+"\" -new \""+ptout) cmdn=string.replace(cmdn,pout,ptout) + recdblist.printutf8(cmdn) txt="" try: txt=execcomd(cmdn) @@ -338,9 +359,12 @@ def addmp4(padd,pout,cmd):#without video txt= "error occures in addmp4\n" txt=txt+ str(type(inst))+"\n" txt=txt+str(inst) - recdblist.addlog(pin, txt, "MP4Box-log-add") - time.sleep(3) + recdblist.addlog(pout, txt, "MP4Box-log-add") + time.sleep(5) + os.remove(ptoutb) + shutil.move(ptadd,padd) shutil.move(ptout,pout) + time.sleep(5) def execcomd(cmd): txt="" try: