X-Git-Url: http://git.osdn.net/view?p=rec10%2Frec10-git.git;a=blobdiff_plain;f=rec10%2Ftrunk%2Fsrc%2Fts2x264.py;h=63ef8ff46287c7693bb91c5e172ac598d45b387a;hp=474244fe23da508965a9edcd80212d56ffa81183;hb=50f90c1b522eb4445a25d03bc083cbdb5fa5970b;hpb=f6960793b96db30994518b1491ff71bbf8970865 diff --git a/rec10/trunk/src/ts2x264.py b/rec10/trunk/src/ts2x264.py index 474244f..63ef8ff 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" @@ -379,7 +385,13 @@ def getMovieBaseSize(pin): def getMovieBaseSize2(pin):##動画開始後すぐに解像度が変更されたときに対処 ffmpeg=configreader.getConfPath("ffmpeg") os.environ['LANG']="ja_JP.UTF-8" - exe=ffmpeg+u" -ss 5 -fs 1 -i \""+pin+"\" \""+pin+".size.ts\" 2>&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") sizeMaxX=0 @@ -430,7 +442,13 @@ def getMoviePAR(pin): def getMoviePAR2(pin): ffmpeg=configreader.getConfPath("ffmpeg") os.environ['LANG']="ja_JP.UTF-8" - exe=ffmpeg+u" -ss 5 -fs 1 -i \""+pin+"\" \""+pin+".size.ts\" 2>&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") sizeMaxX=0 @@ -487,7 +505,7 @@ def getMovieDAR(pin): def getMovieDAR2(pin): ffmpeg=configreader.getConfPath("ffmpeg") os.environ['LANG']="ja_JP.UTF-8" - exe=ffmpeg+u" -ss 5 -fs 1 -i \""+pin+"\" \""+pin+".size.ts\" 2>&1" + exe=ffmpeg+u" -ss 5 -fs 1 -t 10 -i \""+pin+"\" \""+pin+".size.ts\" 2>&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 @@ -528,7 +546,9 @@ def getParSize(pin,y): return [tX,tY] def getX264CoreVersion(): x264=configreader.getConfPath("x264") + #print x264 t1=commands.getoutput(x264+" --help|grep core") + #print t1 rT=re.compile(u"x264 core:(\d*)[\d]*.*\Z") rM=rT.match(t1) v=-1 @@ -551,21 +571,38 @@ def getX264Commandline(preset,sar,fps,x264profile,x264tune,pout,pin,x264streamsi if interlaced==1: x264interlaced="--tff --nal-hrd vbr" if bluray==1: - x264bluray="--weightp 1 --nal-hrd vbr --bframes 3 --b-pyramid none --open-gop bluray --slices 4 --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 3 "+x264bluray - elif fps=="30000/1001 --keyint 30" or fps =="30000/1001": - if x264streamsize=="1280x720": - x264bluray=u"--ref 6 "+x264bluray - if x264streamsize=="1920x1080": - if interlaced==0: - x264bluray=u"--ref 3 --fake-interlaced --pic-struct "+x264bluray - else: - x264bluray=u"--ref 3 "+x264bluray + if getX264CoreVersion()<115: + x264bluray=" --weightp 1 --nal-hrd vbr --bframes 3 --b-pyramid none --open-gop bluray --slices 4 --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 + elif getX264CoreVersion()>=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") @@ -577,7 +614,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