3 # Rec10 TS Recording Tools
4 # Copyright (C) 2009 Yukikaze
10 def ts2x264(pin, pout, opts):#sizeは"HD"か"SD"
12 pinで指定されたファイルをpoutにx264でエンコードして書き出す
17 if re.search("2", opts):
19 if re.search("H", opts):
21 if re.search("S", opts):
23 if re.search("F", opts):
25 if re.search("L", opts):
27 if re.search("G", opts):
29 if re.search("v", opts):
31 encode(pin, pout,size,isvfr,dualpass)
32 def encode(pin,pout,size,isvfr,is2pass):
35 encvf="-vf yadif=0,pp=ac"
37 ofps="-ofps 30000/1001"
44 ofps="-ofps 120000/1001"
45 encvf="-vf pullup,softskip,pp=ac"
46 #encvf="-vf filmdint=io=2997:119880,pp=mb"
48 x264enc1=":me=hex:bframes=3"
49 x264enc2=":frameref=3:subq=7:partitions=all:8x8dct:direct=auto:me=umh:bframes=3:weight_b"
52 encvf = encvf + ",scale=1280:720::0:4"+harddup
53 bitrate = "bitrate=" + str(tv2avi.Bitrate_HD*bm)
56 encvf = encvf + ",scale=720:480::0:4"+harddup
57 bitrate = "bitrate=" + str(tv2avi.Bitrate_SD*bm)
60 encvf = encvf + ",scale=1920:1080::0:4"+harddup
61 bitrate = "bitrate=" + str(tv2avi.Bitrate_FHD*bm)
64 encvf = encvf +harddup
65 bitrate = "bitrate=" + str(tv2avi.Bitrate_Short*bm)
68 encvf = encvf + ",scale=1280:720::0:4"+harddup
69 bitrate = "bitrate=" + str(tv2avi.Bitrate_LowHD*bm)
72 encvf = encvf + ",scale=1280:720::0:4"+harddup
73 bitrate = "bitrate=" + str(tv2avi.Bitrate_HD*bm)
76 pas1exe = "mencoder \'" + pin + "\' -quiet -nosound -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc1+ ":threads=auto:level_idc=41:pass=1:turbo=2 -passlogfile \'" + pin + ".log\' " + " -o /dev/null"
77 pas2exe = "mencoder \'" + pin + "\' -quiet -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc2+ ":level_idc=42:threads=auto:pass=2 -passlogfile \'" + pin + ".log\' -oac faac -o \'" + pout + "\'"
78 pas1exe = "nice -n 19 " + pas1exe
79 pas2exe = "nice -n 19 " + pas2exe
80 recdblist.printutf8(pas1exe)
81 txt=txt+unicode(commands.getoutput(pas1exe.encode('utf-8')),'utf-8')
82 recdblist.printutf8(pas2exe)
84 txt=txt+unicode(commands.getoutput(pas2exe.encode('utf-8')),'utf-8')
86 pas1exe = "mencoder \'" + pin + "\' -quiet -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc2+":level_idc=42:threads=auto -oac faac -o \'" + pout + "\'"
87 pas1exe = "nice -n 19 " + pas1exe
88 recdblist.printutf8(pas1exe)
89 txt=txt+unicode(commands.getoutput(pas1exe.encode('utf-8')),'utf-8')
91 logo=logo.replace(".sa.avi",".ts")
92 logo=logo.replace(".ts",".log")
104 txt="\n####mencoder-log_"+size+"####\n"+stxt
105 f.write(txt.encode('utf-8'))