From b0df1e8ad32a253f41a9e6a45ba991ebd7bb31bf Mon Sep 17 00:00:00 2001 From: gn64_jp Date: Mon, 8 Mar 2010 00:44:51 +0000 Subject: [PATCH] simplify codes. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@466 4e526526-5e11-4fc0-8910-f8fd03428081 --- rec10/trunk/src/install.py | 6 ++++-- rec10/trunk/src/readme.txt | 3 +++ rec10/trunk/src/rec10.conf | 5 ++++- rec10/trunk/src/ts2x264.py | 13 +++++++++---- rec10/trunk/src/tv2mkv.py | 5 +++-- rec10/trunk/src/tv2mp4.py | 12 +++--------- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/rec10/trunk/src/install.py b/rec10/trunk/src/install.py index 79670c7..3019438 100644 --- a/rec10/trunk/src/install.py +++ b/rec10/trunk/src/install.py @@ -76,13 +76,15 @@ def getpath(cmd): return txt.strip() def move(): path = str(os.path.dirname(os.path.abspath(__file__))) - recdblist.printutf8(u"rec10 ver 0.9.2 installer.") + recdblist.printutf8(u"rec10 ver 0.9.3 installer.") recdblist.printutf8(u"rec10のインストールを開始します。") maxn=12 configwriter.setpath(u"wine", getpath(u"wine")) configwriter.setpath(u"recpt1", getpath(u"recpt1")) - + configwriter.setpath(u"x264", getpath(u"x264")) configwriter.setpath(u"MP4Box", getpath(u"MP4Box")) + configwriter.setpath(u"mencoder", getpath(u"mencoder")) + configwriter.setpath(u"ffmpeg", getpath(u"ffmpeg")) #configwriter.setpath(u"xvfb-run", getpath(u"xvfb-run")) configwriter.setpath(u"mkvmerge", getpath(u"mkvmerge")) configwriter.setpath(u"b25", getpath(u"b25")) diff --git a/rec10/trunk/src/readme.txt b/rec10/trunk/src/readme.txt index 434fc7d..2cf5aa8 100644 --- a/rec10/trunk/src/readme.txt +++ b/rec10/trunk/src/readme.txt @@ -68,6 +68,9 @@ chdata.pyを実行してください(python chdata.py) yukikaze.jp@gmail.com [History] +0.9.3 release(internal) +lots of bug fixes. +change DB. 10/03/06 0.9.2 release(internal) few bug fix.(!!! amazing i think) implement new encoding system. diff --git a/rec10/trunk/src/rec10.conf b/rec10/trunk/src/rec10.conf index 9a0636e..e342eb0 100644 --- a/rec10/trunk/src/rec10.conf +++ b/rec10/trunk/src/rec10.conf @@ -2,7 +2,9 @@ recpt1 = /usr/local/bin/recpt1 wine = /usr/bin/wine xvfb-run = /usr/local/share/rec10/tstools/xvfb-run - +x264 = /usr/bin/x264 +mencoder = /usr/bin/mencoder +ffmpeg = /usr/bin/ffmpeg rec10 = /usr/local/share/rec10 #recpathは録画先のフォルダを指定 @@ -56,3 +58,4 @@ make_mp4 = 1 x264_preset=4 crf=24 animation_crf=20 +x264_addline = diff --git a/rec10/trunk/src/ts2x264.py b/rec10/trunk/src/ts2x264.py index 1cf1722..9800367 100644 --- a/rec10/trunk/src/ts2x264.py +++ b/rec10/trunk/src/ts2x264.py @@ -63,6 +63,8 @@ def ts2x264(pin, pout, opts):#sizeは"HD"か"SD" print type(inst) print inst def encode(pin,pout,size,is24fps,quality,crf): + mencoder=configreader.getpath("mencoder") + x264=configreader.getpath("x264") encvf="" txt="" encvf="-vf yadif=0,pp=l5" @@ -74,6 +76,7 @@ def encode(pin,pout,size,is24fps,quality,crf): x264preset="" x264tune="" x264_maxrate="10000" + x264_addline=configreader.getenv("x264_addline") if is24fps==1: ofps="-ofps 24000/1001" fps="-fps 30000/1001" @@ -119,8 +122,8 @@ def encode(pin,pout,size,is24fps,quality,crf): random.jumpahead(10) streampath=os.path.join(os.path.dirname(pin),str(random.randint(10000, 999999))) os.system(u"mkfifo "+streampath) - encexe=u"mencoder \""+pin+u"\" -vfm ffmpeg -quiet -sws 9 "+encvf+u",format=i420 "+fps+" "+ofps+" -oac mp3lame -ovc raw -of rawvideo -o \""+streampath+"\" &" - encexe=encexe+u" nice -n 19 x264 "+x264crf+" --vbv-bufsize "+str(int(x264_maxrate)*2)+u" --vbv-maxrate "+x264_maxrate+u" --level 41 --profile high "+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+streampath+" "+x264streamsize + encexe=mencoder+u" \""+pin+u"\" -vfm ffmpeg -quiet -sws 9 "+encvf+u",format=i420 "+fps+" "+ofps+" -oac mp3lame -ovc raw -of rawvideo -o \""+streampath+"\" &" + encexe=encexe+u" nice -n 19 "+x264+" "+x264crf+u" "+x264_addline+u" "+u" --vbv-bufsize "+str(int(x264_maxrate)*2)+u" --vbv-maxrate "+x264_maxrate+u" --level 41 --profile high "+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+streampath+" "+x264streamsize encexe=u"nice -n 19 " +encexe recdblist.printutf8(encexe) txt=txt+"Cmd : "+encexe+"\n" @@ -137,13 +140,15 @@ def encode_ffmpeg(pin,pout,size,is24fps,quality,crf): """ """ - ffmpeg="ffmpeg" + ffmpeg=configreader.getpath("ffmpeg") + x264=configreader.getpath("x264") fps=u"-r 29.970030 " x264fps="--fps 30000/1001" x264streamsize="" x264preset="" x264tune="" x264_maxrate="10000" + x264_addline=configreader.getenv("x264_addline") if size == "HD": s = "-s 1280x720 " x264streamsize=u"1280x720" @@ -180,7 +185,7 @@ def encode_ffmpeg(pin,pout,size,is24fps,quality,crf): txt="" os.environ['LANG']="ja_JP.UTF-8" exe=ffmpeg+u" -y -i \""+pin+"\" -vsync 400 -vcodec rawvideo -pix_fmt yuv420p "+s+fps+"-deinterlace -an -f rawvideo - |" - exe=exe+u" nice -n 19 x264 "+x264crf+" --vbv-bufsize "+str(int(x264_maxrate)*2)+u" --vbv-maxrate "+x264_maxrate+u" --level 41 --profile high "+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" - "+x264streamsize + exe=exe+u" nice -n 19 "+x264+" "+x264crf+u" "+x264_addline+u" --vbv-bufsize "+str(int(x264_maxrate)*2)+u" --vbv-maxrate "+x264_maxrate+u" --level 41 --profile high "+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" - "+x264streamsize txt=txt+"Cmd : "+exe+"\n" exe = "nice -n 19 " + exe txt=txt+"Cmd : "+exe+"\n" diff --git a/rec10/trunk/src/tv2mkv.py b/rec10/trunk/src/tv2mkv.py index ee0004e..3516e25 100644 --- a/rec10/trunk/src/tv2mkv.py +++ b/rec10/trunk/src/tv2mkv.py @@ -31,6 +31,7 @@ def raw2mkv(pin,pout,opt):#x264 title=os.path.split(pout)[1] title=os.path.splitext(title)[0] duration="--default-duration 0:30000/1001fps " + ffmpeg=configreader.getpath("ffmpeg") isdualaac=0 ispentaaudio=0 if re.search("a",opt): @@ -95,7 +96,7 @@ def raw2mkv(pin,pout,opt):#x264 pints=pin.replace(".264",".ts") 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+"\"" + e1=ffmpeg+" -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\"" e2=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --track-order 0:0,1:0" e2s=exe +" -o \""+pout+u"\" --forced-track 0:no "+duration+"-d 0 -A -S \""+pin+"\" --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:0,2:0" if os.path.isfile(cap2ass): @@ -175,7 +176,7 @@ def avi2mkv(pin,pout,opt): pints=pin.replace(".avi",".ts") pinaac=pin.replace(".avi",".aac") e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\"" - e1="ffmpeg -i \""+pints+"\" -vn -f aac -acodec copy \""+pinaac+"\"" + e1=ffmpeg+u" -i \""+pints+u"\" -vn -f aac -acodec copy \""+pinaac+"\"" e2=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --track-order 0:0,1:0" e2s=exe +" -o \""+pout+u"\" --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:0,2:0" if os.path.isfile(cap2ass): diff --git a/rec10/trunk/src/tv2mp4.py b/rec10/trunk/src/tv2mp4.py index fddf923..ac30a9c 100644 --- a/rec10/trunk/src/tv2mp4.py +++ b/rec10/trunk/src/tv2mp4.py @@ -19,13 +19,6 @@ 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") - 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)""" tpraw=os.path.join(dir, title+".264") tpmp4=os.path.join(dir, title+".mp4") tv2avi.ts2raw(pin, tpraw, opt) @@ -36,6 +29,7 @@ def raw2mp4(pin,pout,opt): title=os.path.split(pout)[1] title=os.path.splitext(title)[0] duration="-fps 29.970030 " + ffmpeg=configreader.getpath("ffmpeg") isdualaac=0 ispentaaudio=0 if re.search("a",opt): @@ -106,7 +100,7 @@ def raw2mp4(pin,pout,opt): pints=pin.replace(".264",".ts") 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+"\"" + 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+"\"" @@ -147,7 +141,7 @@ def avi2mp4(pin,pout,opt): pintimecode=os.path.join(dir,etitle+u".timecode.txt") pinaac=os.path.join(dir,etitle+u".aac") pincat=os.path.join(dir,etitle+u".srt") - evfr0="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'" + evfr0=ffmpeg+u" -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'" evfr1=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' 'Z:\\"+pintimecode+u"' 2" evfr2=exe+u" -aviraw video \'"+pin120+u"\'" videotpath=os.path.join(dir,etitle+u".120_video.h264") -- 2.11.0