From 7e28f9a40b5c06d9d9feb7633af380bde72559d3 Mon Sep 17 00:00:00 2001 From: gn64_jp Date: Mon, 21 Dec 2009 14:25:55 +0000 Subject: [PATCH] fix mp4 vfr. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@333 4e526526-5e11-4fc0-8910-f8fd03428081 --- rec10/trunk/src/timerec.py | 6 +++--- rec10/trunk/src/tv2mp4.py | 47 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/rec10/trunk/src/timerec.py b/rec10/trunk/src/timerec.py index 6b50b01..1bb2d55 100644 --- a/rec10/trunk/src/timerec.py +++ b/rec10/trunk/src/timerec.py @@ -486,13 +486,13 @@ def type_encode_que(typetxt,chtxt,title,bt,et,opt): if re.search("5", opt): pin = recpath + "/" + title + ".sa.avi" #pout = recpath + "/" + title + ".avi" - pout = recpath + "/" + title + ".mp4" + pout = recpath + "/" + title + ".mkv" recdblist.printutf8(pin) #recdblist.printutf8(pin+":"+pout+":"+opt) recdb.del_reckey(typetxtnow, title, chtxt, btime) recdb.rec_reckey(typetxting, title, chtxt, btime, etime, opt) - #tv2mkv.ts2mkv(pin, pout, opt) - tv2mp4.ts2mp4(pin, pout, opt) + tv2mkv.ts2mkv(pin, pout, opt) + #tv2mp4.ts2mp4(pin, pout, opt) #tv2avi.ts2avi(pin, pout, opt) recdb.del_reckey(typetxting, title, chtxt, btime) if re.search("E", opt): diff --git a/rec10/trunk/src/tv2mp4.py b/rec10/trunk/src/tv2mp4.py index 41959a5..cb64d53 100644 --- a/rec10/trunk/src/tv2mp4.py +++ b/rec10/trunk/src/tv2mp4.py @@ -3,10 +3,12 @@ # Rec10 TS Recording Tools # Copyright (C) 2009 Yukikaze import commands +import shutil import tv2avi import os import re import os.path +import base64 import time import recdblist import configreader @@ -31,7 +33,7 @@ def avi2mp4(pin,pout,opt): title=os.path.split(pin)[1] title=os.path.splitext(title)[0] audiopath=os.path.join(dir,title+u"_audio.raw") - videopath=os.path.join(dir,title+u"_video.h264") + videopath=os.path.join(dir,title+u"_video.264") exes=[] os.environ['LANG']="ja_JP.UTF-8" txt="" @@ -48,7 +50,7 @@ def avi2mp4(pin,pout,opt): evfr.append("ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'") evfr.append(wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' 'Z:\\"+pintimecode+u"' 2") evfr.append(exe+u" -aviraw video \'"+pin120+u"\'") - videotpath=os.path.join(dir,title+u".120_video.h264") + videotpath=os.path.join(dir,title+u".120_video.264") evfr.append(exe+u" -fps 29.970030 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'") #evfr.append(exe+u" -add \'"+pinaac+"\' \'"+pmp4+"\'") evfr.append(wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'") @@ -113,7 +115,7 @@ def avi2mp4(pin,pout,opt): delpath.append(pin.replace(u".avi",u".ts")) delpath.append(pin.replace(u".avi",u".aac")) delpath.append(pin.replace(u".avi",u".m2v")) - delpath.append(pin.replace(u".avi",u".120_video.h264")) + delpath.append(pin.replace(u".avi",u".120_video.264")) delpath.append(pin.replace(u".avi",u".ts.b25")) if os.path.exists(pout): if os.path.exists(audiopath): @@ -135,26 +137,41 @@ def mkv2mp4(pin,pout): dir=os.path.split(pin)[0] title=os.path.split(pin)[1] title=os.path.splitext(title)[0] - audiopath=os.path.join(dir,title+u"_audio.raw") - videopath=os.path.join(dir,title+u"_video.h264") - timecodepath=os.path.join(dir,title+u"_1_timecode.txt") - tmpmp4=os.path.join(dir,title+u".tmp.mp4") + etitle=base64.b16encode(title.encode('utf-8')) + audiopath=os.path.join(dir,etitle+u"_audio.raw") + videopath=os.path.join(dir,etitle+u"_video.264") + timecodepath=os.path.join(dir,etitle+u"_1_timecode.txt") + tmpmp4=os.path.join(dir,etitle+u".tmp.mp4") + tmpmp42=os.path.join(dir,etitle+u".mp4") exe0=exeb+u" tracks \'"+pin+u"\' 1:\'"+videopath+u"\' 2:\'"+audiopath+u"\'" exe1=exeb+u" timecodes_v2 \'"+pin+"\' 1:\'"+timecodepath+"\'" - exe2=exe+u" -fps 29.970030 -add \'"+videopath+u"\' -add \'"+audiopath+u"\' -new \'"+tmpmp4+u"\'" - exe3=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+timecodepath+u"\' \'Z:\\"+tmpmp4+u"\' -o \'Z:\\"+pout+u"\'" + exe2=exe+u" -fps 29.970030 -add \'"+videopath+u"\' -new \'"+tmpmp4+u"\'" + exe3=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+timecodepath+u"\' \'Z:\\"+tmpmp4+u"\' -o \'Z:\\"+tmpmp42+u"\'" + exe4=exe+u" -add \'"+audiopath+u"\' \'"+tmpmp42+u"\'" logo=pin.replace(".avi",".log") os.environ['LANG']="ja_JP.UTF-8" txt= exe0+"\n"+exe1+"\n"+exe2+"\n"+exe3+"\n" try: txt = txt+unicode(commands.getoutput(exe0.encode('utf-8')),'utf-8') + except: + "" + try: txt = txt+unicode(commands.getoutput(exe1.encode('utf-8')),'utf-8') + except: + "" + try: txt = txt+unicode(commands.getoutput(exe2.encode('utf-8')),'utf-8') - txt = txt+unicode(commands.getoutput(exe3.encode('utf-8')),'utf-8') except: "" - os.remove(audiopath) - os.remove(videopath) + try: + commands.getoutput(exe3.encode('utf-8')) + except: + "" + try: + txt = txt+unicode(commands.getoutput(exe4.encode('utf-8')),'utf-8') + except: + "" + shutil.move(tmpmp42,pout) txt = "\n####MKV2MP4-log####\n"+txt f=open(logo,'a') f.write(txt.encode('utf-8')) @@ -165,3 +182,9 @@ def mkv2mp4(pin,pout): os.remove(audiopath) if os.path.exists(videopath): os.remove(videopath) + if os.path.exists(timecodepath): + os.remove(timecodepath) + if os.path.exists(tmpmp4): + os.remove(tmpmp4) + if os.path.exists(tmpmp42): + os.remove(tmpmp42) \ No newline at end of file -- 2.11.0