X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=blobdiff_plain;f=rec10%2Ftrunk%2Fsrc%2Fts2x264.py;h=8f77cc97a4dee9fc9f87e43201b25508563d308b;hp=6e071c35911cc9ed81dc56fde5b899664bb8b4ef;hb=ce981efe4240288caf1d4f84ee2a1fa6a3c742f7;hpb=bfb46863dfc3d2ea126eb7da047739cf61a25f93 diff --git a/rec10/trunk/src/ts2x264.py b/rec10/trunk/src/ts2x264.py index 6e071c3..8f77cc9 100644 --- a/rec10/trunk/src/ts2x264.py +++ b/rec10/trunk/src/ts2x264.py @@ -6,6 +6,7 @@ import commands import configreader import os import os.path +import sys import re import random import time @@ -38,9 +39,11 @@ def ts2x264(pin, pout, opts):#sizeは"HD"か"SD" if re.search("MW1",opts): size = "QVGA_BASE" crf=crf+4 + sar=0 if re.search("MW2", opts): size = "WVGA_BASE" crf=crf+2 + sar=0 if re.search("v", opts): is24fps=1 crf=int(configreader.getConfEnv("animation_crf")) @@ -186,6 +189,9 @@ def encodeMencoderSar(pin,pout,size,is24fps,quality,crf,deinterlace=1,uselavf=0, harddup=",harddup" encvf=encvf+harddup x264streamsize=str(tsize[0])+u"x"+str(tsize[1]) + if usebluray==1: + encvf = u"-sws 9 "+encvf + ",scale=-2:1080::0:3,expand=1920:1080"+harddup + x264streamsize=u"1920x1080" if tsize[0] <= 0 or tsize[1] <= 0: encvf="-sws 9 -vf yadif=0,pp=l5" harddup=",hqdn3d=2:1:2,unsharp=l3x3:0.75:c3x3:0.75,harddup" @@ -354,39 +360,25 @@ def encodeFfmpegSar(pin,pout,size,is24fps,quality,crf,deinterlace=1,usebluray=0, zip.addFile2FileZip(log_x264, recdblist.getLogTitle(pin+".log.zip")) os.remove(log_ffmpeg) os.remove(log_x264) -def getMovieBaseSize(pin): - ffmpeg=configreader.getConfPath("ffmpeg") - os.environ['LANG']="ja_JP.UTF-8" - exe=ffmpeg+u" -i \""+pin+"\" 2>&1" - txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore') - rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z") - sizeMaxX=0 - sizeMaxY=0 - txtls=txts.split("\n") - for t in txtls: - rM=rT.match(t) - if rM: - sizetxt=rM.group(1) - partxt=rM.group(2) - tX=int(sizetxt.split("x")[0]) - tY=int(sizetxt.split("x")[1]) - tEX=int(partxt.split(":")[0]) - tEY=int(partxt.split(":")[1]) - if sizeMaxX&1" + exe=ffmpeg+u" -ss 5 -fs 1 -t 10 -i \""+pin+"\" \""+pin+".size.ts\" 2>&1" + try: + recdblist.addCommandSelfLog(pin, exe) + except Exception, inst: + print type(inst) + print str(inst) + print traceback.print_exc(file=sys.stdout) txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore') rT=re.compile(u"Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z") + rT2=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+SAR\D+(\d+:\d+)\D+.*DAR\D+(\d+:\d+)\D+.*\Z") sizeMaxX=0 sizeMaxY=0 txtls=txts.split("\n") for t in txtls: rM=rT.search(t) + rM2=rT2.search(t) if rM: sizetxt=rM.group(1) partxt=rM.group(2) @@ -397,122 +389,84 @@ def getMovieBaseSize2(pin):##動画開始後すぐに解像度が変更された if sizeMaxX&1" - txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore') - rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z") - sizeMaxX=0 - parx=0 - pary=0 - txtls=txts.split("\n") - for t in txtls: - rM=rT.match(t) - if rM: - sizetxt=rM.group(1) - dartxt=rM.group(2) - tX=int(sizetxt.split("x")[0]) - tY=int(sizetxt.split("x")[1]) - tEX=int(dartxt.split(":")[0]) - tEY=int(dartxt.split(":")[1]) - if sizeMaxX&1" - txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore') - rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z") - sizeMaxX=0 - parx=0 - pary=0 - txtls=txts.split("\n") - for t in txtls: - rM=rT.match(t) - if rM: - sizetxt=rM.group(1) - dartxt=rM.group(2) + if rM2: + sizetxt=rM2.group(1) tX=int(sizetxt.split("x")[0]) tY=int(sizetxt.split("x")[1]) - tEX=int(dartxt.split(":")[0]) - tEY=int(dartxt.split(":")[1]) if sizeMaxX&1" - txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore') - rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+.*DAR\D+(\d+:\d+)\D+.*\Z") - sizeMaxX=0 - darx=0 - dary=0 - txtls=txts.split("\n") + exe=ffmpeg+u" -ss 5 -fs 1 -t 10 -i \""+pin+"\" \""+pin+".size.ts\" 2>&1" + try: + recdblist.addCommandSelfLog(pin, exe) + except Exception, inst: + print type(inst) + print str(inst) + print traceback.print_exc(file=sys.stdout) + txts = unicode(commands.getoutput(exe.encode('utf-8')), 'utf-8', 'ignore') + rT = re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z") + rT2 = re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+SAR\D+(\d+:\d+)\D+.*DAR\D+(\d+:\d+)\D+.*\Z") + sizeMaxX = 0 + parx = 0 + pary = 0 + txtls = txts.split("\n") for t in txtls: - rM=rT.match(t) + rM = rT.match(t) + rM2 = rT2.match(t) if rM: - sizetxt=rM.group(1) - dartxt=rM.group(2) - tX=int(sizetxt.split("x")[0]) - tY=int(sizetxt.split("x")[1]) - tEX=int(dartxt.split(":")[0]) - tEY=int(dartxt.split(":")[1]) - if sizeMaxX&1" - txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore') - rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+.*DAR\D+(\d+:\d+)\D+.*\Z") - sizeMaxX=0 - darx=0 - dary=0 - txtls=txts.split("\n") - for t in txtls: - rM=rT.match(t) - if rM: - sizetxt=rM.group(1) - dartxt=rM.group(2) - tX=int(sizetxt.split("x")[0]) - tY=int(sizetxt.split("x")[1]) - tEX=int(dartxt.split(":")[0]) - tEY=int(dartxt.split(":")[1]) - if sizeMaxX=115: + x264bluray=" --slices 4 --bluray-compat --nal-hrd vbr --bframes 3 --b-pyramid strict --aud --colorprim bt709 --transfer bt709 " + x264_addline="" + if fps=="24000/1001 --keyint 24" or fps =="24000/1001": + if x264streamsize=="1280x720": + x264bluray=u"--ref 6 "+x264bluray + if x264streamsize=="1920x1080": + x264bluray=u"--ref 4 "+x264bluray + elif fps=="30000/1001 --keyint 30" or fps =="30000/1001": + if x264streamsize=="1280x720": + x264bluray=u"--ref 6 --pulldown double "+x264bluray + if x264streamsize=="1920x1080": + if interlaced==0: + x264bluray=u"--ref 4 --fake-interlaced --pic-struct "+x264bluray + else: + x264bluray=u"--ref 4 "+x264bluray x264_thread="auto" try: xtt=configreader.getConfEnv("x264_thread") @@ -564,7 +550,7 @@ def getX264Commandline(preset,sar,fps,x264profile,x264tune,pout,pin,x264streamsi x264_addline=configreader.getConfEnv("x264_addline") if getX264CoreVersion()>103: x264res=u"--input-res "+x264streamsize - exe=u"nice -n 19 "+x264+" "+x264_sar+" "+x264crf+u" "+x264bluray+u" "+x264interlaced+u" "+x264_addline+u" --colormatrix bt709 --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" "+x264res+" -o \""+pout+"\" "+pin + exe=u"nice -n 19 "+x264+" --demuxer raw --vbv-maxrate 30000 --vbv-bufsize 25000 "+x264_sar+" "+x264crf+u" "+x264bluray+u" "+x264interlaced+u" "+x264_addline+u" --colormatrix bt709 --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" "+x264res+" -o \""+pout+"\" "+pin else: - exe=u"nice -n 19 "+x264+" "+x264_sar+" "+x264crf+u" "+x264bluray+u" "+x264interlaced+u" "+x264_addline+u" --colormatrix bt709 --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+pin+" "+x264streamsize + exe=u"nice -n 19 "+x264+" --demuxer raw --vbv-maxrate 30000 --vbv-bufsize 25000 "+x264_sar+" "+x264crf+u" "+x264bluray+u" "+x264interlaced+u" "+x264_addline+u" --colormatrix bt709 --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+pin+" "+x264streamsize return exe