3 # Rec10 TS Recording Tools
\r
4 # Copyright (C) 2009-2011 Yukikaze
\r
16 def ts2x264(pin, pout, opts):#sizeは"HD"か"SD"
\r
18 pinで指定されたファイルをpoutにx264でエンコードして書き出す
\r
25 quality=int(configreader.getConfEnv("x264_preset"))
\r
26 crf=int(configreader.getConfEnv("crf"))
\r
28 if re.search("H", opts):
\r
30 if re.search("S", opts):
\r
32 if re.search("F", opts):
\r
34 if re.search("W",opts):
\r
36 if re.search("MW1",opts):
\r
39 if re.search("MW2", opts):
\r
42 if re.search("v", opts):
\r
44 crf=int(configreader.getConfEnv("animation_crf"))
\r
45 if re.search("a", opts):
\r
47 crf=int(configreader.getConfEnv("animation_crf"))
\r
48 if re.search("I", opts):
\r
50 if re.search("q",opts):
\r
52 if re.search("w",opts):
\r
54 if re.search("e",opts):
\r
56 if re.search("r",opts):
\r
58 if re.search("u",opts):
\r
60 if re.search("i",opts):
\r
62 if re.search("o",opts):
\r
64 if re.search("p",opts):
\r
66 if re.search("d",opts):#二カ国語放送の場合
\r
67 tm2v=pin.replace(".ts",".m2v")
\r
68 encodeFfmpegSar(tm2v,pout,size,is24fps,quality,crf,deinterlace)
\r
69 elif re.search("5",opts):#5.1chの場合
\r
70 encodeFfmpegSar(pin,pout,size,is24fps,quality,crf,deinterlace)
\r
71 elif re.search("0",opts):#BonTsDemuxを使いたい場合
\r
73 elif re.search("X",opts):
\r
75 encodeMencoderSar_lavf(pin, pout,size,is24fps,quality,crf,deinterlace)
\r
76 except Exception, inst:
\r
77 recdblist.addCommonlogEX("Error in X", "ts2x264(ts2x264.py)", str(type(inst)), str(inst)+traceback.format_exc(),log_level=200)
\r
80 encodeMencoderSar(pin, pout,size,is24fps,quality,crf,deinterlace)
\r
81 except Exception, inst:
\r
82 recdblist.addCommonlogEX("Error", "ts2x264(ts2x264.py)", str(type(inst)), str(inst)+traceback.format_exc(),log_level=200)
\r
83 def encodeMencoderSar(pin,pout,size,is24fps,quality,crf,deinterlace=1):
\r
84 mencoder=configreader.getConfPath("mencoder")
\r
85 tee=configreader.getConfPath("tee")
\r
88 encvf="-sws 9 -vf yadif=0,pp=l5"
\r
89 harddup=",hqdn3d=2:1:2,unsharp=l3x3:0.75:c3x3:0.75,harddup"
\r
90 ofps="-ofps 30000/1001"
\r
91 fps="-fps 30000/1001"
\r
92 x264fps="30000/1001"
\r
97 tsar=getMoviePAR2(pin)
\r
98 x264sar=str(tsar[0])+":"+str(tsar[1])
\r
100 ofps="-ofps 24000/1001"
\r
101 fps="-fps 30000/1001"
\r
102 x264fps="24000/1001"
\r
103 x264tune="--tune animation"
\r
104 encvf="-sws 9 -vf pullup,softskip"
\r
105 harddup=",pp=l5,unsharp=l3x3:0.75:c3x3:0.75,hqdn3d=2:1:2,harddup"
\r
107 tsize=getParSize(pin,720)
\r
108 encvf = encvf + ",scale=-3:720::0:3"+harddup
\r
109 x264streamsize=str(tsize[0])+u"x720"
\r
110 x264_bitrate="2500"
\r
111 elif size == "WVGA":
\r
112 tsize=getParSize(pin,480)
\r
113 encvf = encvf + ",scale=-3:480::0:3"+harddup
\r
114 x264streamsize=str(tsize[0])+u"x480"
\r
115 x264_bitrate="1500"
\r
116 elif size == "FullHD":
\r
117 tsize=getParSize(pin,1080)
\r
118 encvf = encvf + ",scale=-3:1080::0:3"+harddup
\r
119 x264streamsize=str(tsize[0])+u"x1080"
\r
120 x264_bitrate="5000"
\r
121 elif size == "QVGA_BASE":
\r
122 tsize=getParSize(pin,240)
\r
123 encvf = encvf + ",scale=-3:240::0:3"+harddup
\r
124 x264streamsize=str(tsize[0])+u"x240"
\r
126 elif size == "WVGA_BASE":
\r
127 tsize=getParSize(pin,480)
\r
128 encvf = encvf + ",scale=-3:480::0:3"+harddup
\r
129 x264streamsize=str(tsize[0])+u"x480"
\r
130 x264_bitrate="1500"
\r
132 tsize=getParSize(pin,720)
\r
133 encvf = encvf + ",scale=-3:720::0:3"+harddup
\r
134 x264streamsize=str(tsize[0])+u"x720"
\r
135 x264_bitrate="2500"
\r
137 tsize=getMovieBaseSize2(pin)
\r
138 ofps="-ofps 30000/1001"
\r
139 #fps="-fps 30000/1001"
\r
141 x264fps="30000/1001"
\r
142 x264tune=x264tune+" --tff --nal-hrd vbr"
\r
143 encvf="-vf hqdn3d=2:1:2"
\r
145 encvf=encvf+harddup
\r
146 x264streamsize=str(tsize[0])+u"x"+str(tsize[1])
\r
147 if tsize[0] <= 0 or tsize[1] <= 0:
\r
148 encvf="-sws 9 -vf yadif=0,pp=l5"
\r
149 harddup=",hqdn3d=2:1:2,unsharp=l3x3:0.75:c3x3:0.75,harddup"
\r
150 ofps="-ofps 30000/1001"
\r
151 fps="-fps 30000/1001"
\r
152 x264fps="30000/1001"
\r
154 encvf = encvf + ",scale=-2:720::0:3,expand=1280:720"+harddup
\r
155 x264streamsize=u"1280x720"
\r
156 x264_bitrate="2500"
\r
158 x264preset=u"ultrafast"
\r
160 x264preset=u"veryfast"
\r
164 x264preset=u"medium"
\r
168 x264preset=u"slower"
\r
170 x264preset=u"medium"
\r
171 if size == "WVGA_BASE" or size == "QVGA_BASE":
\r
172 x264profile=" --level 32 --profile baseline "
\r
174 x264profile=" --level 41 --profile high "
\r
176 os.environ['LANG']="ja_JP.UTF-8"
\r
178 random.jumpahead(10)
\r
179 temptime=int(time.time())
\r
180 temptime=temptime % 9697
\r
181 random.jumpahead(temptime)
\r
182 streampath=os.path.join(os.path.dirname(pin),str(random.randint(10000, 99999999)))
\r
183 unicode(commands.getoutput(u"mkfifo "+streampath),'utf-8','ignore')
\r
184 logmencoder=recdblist.getLogTitle(pin)+".mencoder.log"
\r
185 logx264=recdblist.getLogTitle(pin)+".x264.log"
\r
186 encexe=mencoder+u" \""+pin+u"\" -quiet -vfm ffmpeg "+encvf+u",format=i420 "+fps+" "+ofps+" -oac mp3lame -ovc raw -of rawvideo -o \""+streampath+"\" 2>&1 | "+tee+" \""+logmencoder+"\" & "
\r
187 encexe=encexe+getX264Commandline(x264preset, x264sar, x264fps, x264profile, x264tune, pout, streampath, x264streamsize, crf=x264crf)
\r
188 #encexe=encexe+u" nice -n 19 "+x264+" "+x264_sar+" "+x264crf+u" "+x264_addline+u" --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+streampath+" "+x264streamsize
\r
189 encexe=u"nice -n 19 " +encexe+" 2>&1 | "+tee+" \""+logx264+"\""
\r
191 recdblist.addCommandSelfLog(pin, encexe)
\r
192 except Exception, inst:
\r
195 print traceback.print_exc(file=sys.stdout)
\r
196 recdblist.printutf8(encexe)
\r
199 txt=unicode(commands.getoutput(encexe.encode('utf-8')),'utf-8','ignore')
\r
202 os.remove(streampath)
\r
203 zip.addFile2FileZip(logmencoder, recdblist.getLogTitle(pin)+".log.zip")
\r
204 zip.addFile2FileZip(logx264, recdblist.getLogTitle(pin)+".log.zip")
\r
205 os.remove(logmencoder)
\r
207 recdblist.addCommandLog(pin, u"Mencoder", encexe, txt)
\r
208 # recdblist.addCommandLogTar(pin,u"Mencoder","mencoder", encexe,txt)
\r
209 def encodeMencoderSar_lavf(pin,pout,size,is24fps,quality,crf,deinterlace=1):
\r
210 mencoder=configreader.getConfPath("mencoder")
\r
211 tee=configreader.getConfPath("tee")
\r
214 encvf="-sws 9 -vf yadif=0,pp=l5"
\r
215 harddup=",hqdn3d=2:1:2,unsharp=l3x3:0.75:c3x3:0.75,harddup"
\r
216 ofps="-ofps 30000/1001"
\r
217 fps="-fps 30000/1001"
\r
218 x264fps="30000/1001"
\r
222 x264_bitrate="5000"
\r
223 tsar=getMoviePAR2(pin)
\r
224 x264sar=str(tsar[0])+":"+str(tsar[1])
\r
226 ofps="-ofps 24000/1001"
\r
227 fps="-fps 30000/1001"
\r
228 x264fps="24000/1001"
\r
229 x264tune="--tune animation"
\r
230 encvf="-sws 9 -vf pullup,softskip"
\r
231 harddup=",pp=l5,unsharp=l3x3:0.75:c3x3:0.75,hqdn3d=2:1:2,harddup"
\r
233 tsize=getParSize(pin,720)
\r
234 encvf = encvf + ",scale=-3:720::0:3"+harddup
\r
235 x264streamsize=str(tsize[0])+u"x720"
\r
236 x264_bitrate="2500"
\r
237 elif size == "WVGA":
\r
238 tsize=getParSize(pin,480)
\r
239 encvf = encvf + ",scale=-3:480::0:3"+harddup
\r
240 x264streamsize=str(tsize[0])+u"x480"
\r
241 x264_bitrate="1500"
\r
242 elif size == "FullHD":
\r
243 tsize=getParSize(pin,1080)
\r
244 encvf = encvf + ",scale=-3:1080::0:3"+harddup
\r
245 x264streamsize=str(tsize[0])+u"x1080"
\r
246 x264_bitrate="5000"
\r
247 elif size == "QVGA_BASE":
\r
248 tsize=getParSize(pin,240)
\r
249 encvf = encvf + ",scale=-3:240::0:3"+harddup
\r
250 x264streamsize=str(tsize[0])+u"x240"
\r
252 elif size == "WVGA_BASE":
\r
253 tsize=getParSize(pin,480)
\r
254 encvf = encvf + ",scale=-3:480::0:3"+harddup
\r
255 x264streamsize=str(tsize[0])+u"x480"
\r
256 x264_bitrate="1500"
\r
258 tsize=getParSize(pin,720)
\r
259 encvf = encvf + ",scale=-3:720::0:3"+harddup
\r
260 x264streamsize=str(tsize[0])+u"x720"
\r
261 x264_bitrate="2500"
\r
263 tsize=getMovieBaseSize2(pin)
\r
264 ofps="-ofps 30000/1001"
\r
265 #fps="-fps 30000/1001"
\r
267 x264fps="30000/1001"
\r
268 x264tune=x264tune+" --tff --nal-hrd vbr"
\r
269 encvf="-vf hqdn3d=2:1:2"
\r
271 encvf=encvf+harddup
\r
272 x264streamsize=str(tsize[0])+u"x"+str(tsize[1])
\r
273 if tsize[0] <= 0 or tsize[1] <= 0:
\r
274 encvf="-sws 9 -vf yadif=0,pp=l5"
\r
275 harddup=",hqdn3d=2:1:2,unsharp=l3x3:0.75:c3x3:0.75,harddup"
\r
276 ofps="-ofps 30000/1001"
\r
277 fps="-fps 30000/1001"
\r
278 x264fps="30000/1001"
\r
280 encvf = encvf + ",scale=-2:720::0:3,expand=1280:720"+harddup
\r
281 x264streamsize=u"1280x720"
\r
282 x264_bitrate="2500"
\r
284 x264preset=u"ultrafast"
\r
286 x264preset=u"veryfast"
\r
290 x264preset=u"medium"
\r
294 x264preset=u"slower"
\r
296 x264preset=u"medium"
\r
297 if size == "WVGA_BASE" or size == "QVGA_BASE":
\r
298 x264profile=" --level 32 --profile baseline "
\r
300 x264profile=" --level 41 --profile high "
\r
302 os.environ['LANG']="ja_JP.UTF-8"
\r
304 random.jumpahead(10)
\r
305 temptime=int(time.time())
\r
306 temptime=temptime % 9697
\r
307 random.jumpahead(temptime)
\r
308 streampath=os.path.join(os.path.dirname(pin),str(random.randint(10000, 99999999)))
\r
309 unicode(commands.getoutput(u"mkfifo "+streampath),'utf-8','ignore')
\r
310 logmencoder=recdblist.getLogTitle(pin)+".mencoder.log"
\r
311 logx264=recdblist.getLogTitle(pin)+".x264.log"
\r
312 encexe=mencoder+u" \""+pin+u"\" -quiet -vfm ffmpeg -demuxer lavf "+encvf+u",format=i420 "+fps+" "+ofps+" -oac mp3lame -ovc raw -of rawvideo -o \""+streampath+"\" 2>&1 | "+tee+" \""+logmencoder+"\" & "
\r
313 encexe=encexe+getX264Commandline(x264preset, x264sar, x264fps, x264profile, x264tune, pout, streampath, x264streamsize, crf=x264crf)
\r
314 #encexe=encexe+u" nice -n 19 "+x264+" "+x264_sar+" "+x264crf+u" "+x264_addline+u" --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+streampath+" "+x264streamsize
\r
315 encexe=u"nice -n 19 " +encexe+" 2>&1 | "+tee+" \""+logx264+"\""
\r
317 recdblist.addCommandSelfLog(pin, encexe)
\r
318 except Exception, inst:
\r
321 print traceback.print_exc(file=sys.stdout)
\r
322 recdblist.printutf8(encexe)
\r
325 txt=unicode(commands.getoutput(encexe.encode('utf-8')),'utf-8','ignore')
\r
328 os.remove(streampath)
\r
329 zip.addFile2FileZip(logmencoder, recdblist.getLogTitle(pin)+".log.zip")
\r
330 zip.addFile2FileZip(logx264, recdblist.getLogTitle(pin)+".log.zip")
\r
331 os.remove(logmencoder)
\r
333 recdblist.addCommandLog(pin, u"Mencoder", encexe, txt)
\r
334 def encodeFfmpegSar(pin,pout,size,is24fps,quality,crf,deinterlace=1):
\r
338 ffmpeg=configreader.getConfPath("ffmpeg")
\r
339 tee=configreader.getConfPath("tee")
\r
340 fps=u"-r 29.970030 "
\r
341 x264fps="30000/1001"
\r
345 x264_bitrate="2500"
\r
347 tsar=getMoviePAR2(pin)
\r
348 filter="-deinterlace"
\r
349 x264sar=str(tsar[0])+":"+str(tsar[1])
\r
351 tsize=getParSize(pin,720)
\r
352 s = "-s "+str(tsize[0])+"x720 "
\r
353 x264streamsize=str(tsize[0])+u"x720"
\r
354 x264_bitrate="2500"
\r
355 elif size == "WVGA":
\r
356 tsize=getParSize(pin,480)
\r
357 s = "-s "+str(tsize[0])+"x480 "
\r
358 x264streamsize=str(tsize[0])+u"x480"
\r
359 x264_bitrate="1500"
\r
360 elif size == "FullHD":
\r
361 tsize=getParSize(pin,1080)
\r
362 s = "-s "+str(tsize[0])+"x1080 "
\r
363 x264streamsize=str(tsize[0])+u"x1080"
\r
364 x264_bitrate="5000"
\r
366 tsize=getParSize(pin,480)
\r
367 s = "-s "+str(tsize[0])+"x480 "
\r
368 x264streamsize=str(tsize[0])+u"x480"
\r
369 x264_bitrate="1250"
\r
370 elif size == "QVGA_BASE":
\r
371 tsize=getParSize(pin,240)
\r
372 s = "-s "+str(tsize[0])+"x240 "
\r
373 x264streamsize=str(tsize[0])+u"x240"
\r
375 elif size == "WVGA_BASE":
\r
376 tsize=getParSize(pin,480)
\r
377 s = "-s "+str(tsize[0])+"x480 "
\r
378 x264streamsize=str(tsize[0])+u"x480"
\r
379 x264_bitrate="1500"
\r
381 tsize=getParSize(pin,720)
\r
382 s = "-s "+str(tsize[0])+"x720 "
\r
383 x264streamsize=str(tsize[0])+u"x720"
\r
384 x264_bitrate="2500"
\r
386 tsize=getMovieBaseSize2(pin)
\r
388 s = "-s "+str(tsize[0])+"x"+str(tsize[1])+" "
\r
389 x264fps="30000/1001"
\r
390 x264tune=x264tune+" --tff --nal-hrd vbr"
\r
392 x264streamsize=str(tsize[0])+u"x"+str(tsize[1])
\r
394 x264preset=u"ultrafast"
\r
396 x264preset=u"veryfast"
\r
400 x264preset=u"medium"
\r
404 x264preset=u"slower"
\r
406 x264preset=u"medium"
\r
407 if size == "WVGA_BASE" or size == "QVGA_BASE":
\r
408 x264profile=" --level 32 --profile baseline "
\r
410 x264profile=" --level 41 --profile high "
\r
413 os.environ['LANG']="ja_JP.UTF-8"
\r
414 log_ffmpeg=recdblist.getLogTitle(pin)+".ffmpeg.log"
\r
415 log_x264=recdblist.getLogTitle(pin)+".x264.log"
\r
416 exe=ffmpeg+u" -y -i \""+pin+"\" -vsync 400 -vcodec rawvideo -pix_fmt yuv420p "+s+fps+" "+filter+" -an -f rawvideo - 2> \""+log_ffmpeg+"\" | "
\r
417 exe=exe+getX264Commandline(x264preset, x264sar, x264fps, x264profile, x264tune, pout,"-", x264streamsize, crf=x264crf)
\r
418 exe = "nice -n 19 " + exe+" 2>&1 | "+tee+" \""+log_x264+"\""
\r
420 #recdblist.addCommandSelfLog(log_ffmpeg,recdblist.getLogTitle(pin)+".log.zip")
\r
421 #recdblist.addCommandSelfLog(log_x264,recdblist.getLogTitle(pin)+".log.zip")
\r
422 recdblist.printutf8(exe)
\r
423 recdblist.addCommandSelfLog(pin,exe)
\r
425 txt=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
428 recdblist.addCommandLog(pin, u"FFmpeg動画エンコード", exe, txt)
\r
429 zip.addFile2FileZip(log_ffmpeg, recdblist.getLogTitle(pin+".log.zip"))
\r
430 zip.addFile2FileZip(log_x264, recdblist.getLogTitle(pin+".log.zip"))
\r
431 os.remove(log_ffmpeg)
\r
432 os.remove(log_x264)
\r
433 def getMovieBaseSize(pin):
\r
434 ffmpeg=configreader.getConfPath("ffmpeg")
\r
435 os.environ['LANG']="ja_JP.UTF-8"
\r
436 exe=ffmpeg+u" -i \""+pin+"\" 2>&1"
\r
437 txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
438 rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z")
\r
441 txtls=txts.split("\n")
\r
445 sizetxt=rM.group(1)
\r
447 tX=int(sizetxt.split("x")[0])
\r
448 tY=int(sizetxt.split("x")[1])
\r
449 tEX=int(partxt.split(":")[0])
\r
450 tEY=int(partxt.split(":")[1])
\r
454 return [sizeMaxX,sizeMaxY]
\r
455 def getMovieBaseSize2(pin):##動画開始後すぐに解像度が変更されたときに対処
\r
456 ffmpeg=configreader.getConfPath("ffmpeg")
\r
457 os.environ['LANG']="ja_JP.UTF-8"
\r
458 exe=ffmpeg+u" -ss 5 -fs 1 -i \""+pin+"\" \""+pin+".size.ts\" 2>&1"
\r
459 txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
460 rT=re.compile(u"Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z")
\r
463 txtls=txts.split("\n")
\r
467 sizetxt=rM.group(1)
\r
469 tX=int(sizetxt.split("x")[0])
\r
470 tY=int(sizetxt.split("x")[1])
\r
471 tEX=int(partxt.split(":")[0])
\r
472 tEY=int(partxt.split(":")[1])
\r
476 os.remove(pin+".size.ts")
\r
477 return [sizeMaxX,sizeMaxY]
\r
478 def getMoviePAR(pin):
\r
479 ffmpeg=configreader.getConfPath("ffmpeg")
\r
480 os.environ['LANG']="ja_JP.UTF-8"
\r
481 exe=ffmpeg+u" -i \""+pin+"\" 2>&1"
\r
482 txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
483 rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z")
\r
487 txtls=txts.split("\n")
\r
491 sizetxt=rM.group(1)
\r
493 tX=int(sizetxt.split("x")[0])
\r
494 tY=int(sizetxt.split("x")[1])
\r
495 tEX=int(dartxt.split(":")[0])
\r
496 tEY=int(dartxt.split(":")[1])
\r
499 if tX==1920 and tY==1080:
\r
506 def getMoviePAR2(pin):
\r
507 ffmpeg=configreader.getConfPath("ffmpeg")
\r
508 os.environ['LANG']="ja_JP.UTF-8"
\r
509 exe=ffmpeg+u" -ss 5 -fs 1 -i \""+pin+"\" \""+pin+".size.ts\" 2>&1"
\r
510 txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
511 rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+PAR\D+(\d+:\d+)\D+.*\Z")
\r
515 txtls=txts.split("\n")
\r
519 sizetxt=rM.group(1)
\r
521 tX=int(sizetxt.split("x")[0])
\r
522 tY=int(sizetxt.split("x")[1])
\r
523 tEX=int(dartxt.split(":")[0])
\r
524 tEY=int(dartxt.split(":")[1])
\r
527 if tX==1920 and tY==1080:
\r
533 os.remove(pin+".size.ts")
\r
535 def getMovieDAR(pin):
\r
536 ffmpeg=configreader.getConfPath("ffmpeg")
\r
537 os.environ['LANG']="ja_JP.UTF-8"
\r
538 exe=ffmpeg+u" -i \""+pin+"\" 2>&1"
\r
539 txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
540 rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+.*DAR\D+(\d+:\d+)\D+.*\Z")
\r
544 txtls=txts.split("\n")
\r
548 sizetxt=rM.group(1)
\r
550 tX=int(sizetxt.split("x")[0])
\r
551 tY=int(sizetxt.split("x")[1])
\r
552 tEX=int(dartxt.split(":")[0])
\r
553 tEY=int(dartxt.split(":")[1])
\r
556 if tX==1920 and tY==1080:
\r
563 def getMovieDAR2(pin):
\r
564 ffmpeg=configreader.getConfPath("ffmpeg")
\r
565 os.environ['LANG']="ja_JP.UTF-8"
\r
566 exe=ffmpeg+u" -ss 5 -fs 1 -i \""+pin+"\" \""+pin+".size.ts\" 2>&1"
\r
567 txts=unicode(commands.getoutput(exe.encode('utf-8')),'utf-8','ignore')
\r
568 rT=re.compile(u".*Stream.*#.*:.*\D+([\d]+x[\d]+)\D+.*DAR\D+(\d+:\d+)\D+.*\Z")
\r
572 txtls=txts.split("\n")
\r
576 sizetxt=rM.group(1)
\r
578 tX=int(sizetxt.split("x")[0])
\r
579 tY=int(sizetxt.split("x")[1])
\r
580 tEX=int(dartxt.split(":")[0])
\r
581 tEY=int(dartxt.split(":")[1])
\r
584 if tX==1920 and tY==1080:
\r
590 os.remove(pin+".size.ts")
\r
592 def getParSize(pin,y):
\r
593 tSize=getMovieBaseSize2(pin)
\r
595 tX=tSize[0]*10*y/tSize[1]
\r
597 if tX>int(tX/10)*10:
\r
605 def getX264CoreVersion():
\r
606 x264=configreader.getConfPath("x264")
\r
607 t1=commands.getoutput(x264+" --help|grep core")
\r
608 rT=re.compile(u"x264 core:(\d*)[\d]*.*\Z")
\r
614 def getX264Commandline(preset,sar,fps,x264profile,x264tune,pout,pin,x264streamsize,crf=-1,bitrate=0):
\r
615 x264=configreader.getConfPath("x264")
\r
616 os.environ['LANG']="ja_JP.UTF-8"
\r
617 x264_sar="--sar "+sar
\r
618 x264preset=u"--preset "+preset
\r
619 x264fps="--fps "+fps
\r
621 x264bitrate=u"--bitrate "+str(bitrate)
\r
623 x264crf=u"--crf "+str(crf)
\r
624 x264_addline=configreader.getConfEnv("x264_addline")
\r
627 xtt=configreader.getConfEnv("x264_thread")
\r
630 x264_thread=str(xtt)
\r
633 x264_addline=configreader.getConfEnv("x264_addline")
\r
634 if getX264CoreVersion()>103:
\r
635 x264res=u"--input-res "+x264streamsize
\r
636 exe=u"nice -n 19 "+x264+" "+x264_sar+" "+x264crf+u" "+x264_addline+u" --colormatrix bt709 --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" "+x264res+" -o \""+pout+"\" "+pin
\r
638 exe=u"nice -n 19 "+x264+" "+x264_sar+" "+x264crf+u" "+x264_addline+u" --colormatrix bt709 --threads "+x264_thread+" "+x264profile+x264preset+" "+x264tune+" "+x264fps+" -o \""+pout+"\" "+pin+" "+x264streamsize
\r