OSDN Git Service

simplify many codes.
[rec10/rec10-git.git] / rec10 / trunk / src / ts2xvid.py
index 37ad146..cc56520 100644 (file)
@@ -2,56 +2,57 @@
 # coding: UTF-8
 # Rec10 TS Recording Tools
 # Copyright (C) 2009 Yukikaze
-import time
+import commands
 import re
+import time
+
 import tv2avi
-import commands
-def ts2xvid(pin,pout,opts):#sizeは"HD"か"SD"
+def ts2xvid(pin, pout, opts):#sizeは"HD"か"SD"
     """
     pinで指定されたファイルをpoutにx264でエンコードして書き出す
     """
     pout = pout.encode('utf-8')
     pin = pin.encode('utf-8')
-    isAnime=0
-    size="SD"
-    if re.search("a",opts):
-        isAnime=1
+    isAnime = 0
+    size = "SD"
+    if re.search("a", opts):
+        isAnime = 1
         #print "isAnime"
-    dualpass=0
-    if re.search("2",opts):
-        dualpass=1
-    if re.search("Q",opts):
-        size="WQVGA"
-    if re.search("F",opts):
-        size="FHD"
-    if re.search("H",opts):
-        size="HD"
-    if re.search("S",opts):
-        size="SD"
-    if isAnime==1:
-        encvf="-vf pullup,softskip,pp=l5,"
+    dualpass = 0
+    if re.search("2", opts):
+        dualpass = 1
+    if re.search("Q", opts):
+        size = "WQVGA"
+    if re.search("F", opts):
+        size = "FHD"
+    if re.search("H", opts):
+        size = "HD"
+    if re.search("S", opts):
+        size = "SD"
+    if isAnime == 1:
+        encvf = "-vf pullup,softskip,pp=l5,"
     else:
-        encvf="-vf pp=l5,"
-    if size=="SD":
-        encvf=encvf+"scale=720:480,harddup"
-        bitrate="bitrate="+tv2avi.Bitrate_SD
-    elif size=="HD":
-        encvf=encvf+"scale=1280:720,harddup"
-        bitrate="bitrate="+tv2avi.Bitrate_HD
-    elif size=="FHD":
-        encvf=encvf+"scale=1920:1080,harddup"
-        bitrate="bitrate="+tv2avi.Bitrate_FHD
-    elif size=="WQVGA":
-        encvf=encvf+"scale=400:240,harddup"
-        bitrate="bitrate="+tv2avi.Bitrate_WQVGA
+        encvf = "-vf pp=l5,"
+    if size == "SD":
+        encvf = encvf + "scale=720:480,harddup"
+        bitrate = "bitrate=" + tv2avi.Bitrate_SD
+    elif size == "HD":
+        encvf = encvf + "scale=1280:720,harddup"
+        bitrate = "bitrate=" + tv2avi.Bitrate_HD
+    elif size == "FHD":
+        encvf = encvf + "scale=1920:1080,harddup"
+        bitrate = "bitrate=" + tv2avi.Bitrate_FHD
+    elif size == "WQVGA":
+        encvf = encvf + "scale=400:240,harddup"
+        bitrate = "bitrate=" + tv2avi.Bitrate_WQVGA
     else:
-        encvf=encvf+"scale=1280:720,harddup"
-        bitrate="bitrate="+tv2avi.Bitrate_HD
-    if dualpass==1:
-        pas1exe="mencoder \'"+pin+"\' -ovc xvid "+encvf+" -xvidencopts "+bitrate+":threads=2:pass=1:turbo -passlogfile \'"+pin+".log\' "+"-oac mp3lame -lameopts cbr:br=128 -o /dev/null"
-        pas2exe="mencoder \'"+pin+"\' -ovc xvid "+encvf+" -xvidencopts "+bitrate+":threads=2:pass=2 -passlogfile \'"+pin+".log\' "+"-oac mp3lame -lameopts cbr:br=128 -o \'"+pout+"\'"
-        pas1exe="nice -n 19 "+pas1exe
-        pas2exe="nice -n 19 "+pas2exe
+        encvf = encvf + "scale=1280:720,harddup"
+        bitrate = "bitrate=" + tv2avi.Bitrate_HD
+    if dualpass == 1:
+        pas1exe = "mencoder \'" + pin + "\' -ovc xvid " + encvf + " -xvidencopts " + bitrate + ":threads=2:pass=1:turbo -passlogfile \'" + pin + ".log\' " + "-oac mp3lame -lameopts cbr:br=128 -o /dev/null"
+        pas2exe = "mencoder \'" + pin + "\' -ovc xvid " + encvf + " -xvidencopts " + bitrate + ":threads=2:pass=2 -passlogfile \'" + pin + ".log\' " + "-oac mp3lame -lameopts cbr:br=128 -o \'" + pout + "\'"
+        pas1exe = "nice -n 19 " + pas1exe
+        pas2exe = "nice -n 19 " + pas2exe
         print pas1exe
         commands.getoutput(pas1exe)
         #os.system(pas1exe)
@@ -60,8 +61,8 @@ def ts2xvid(pin,pout,opts):#sizeは"HD"か"SD"
         commands.getoutput(pas2exe)
         #os.system(pas2exe)
     else:
-        pas1exe="mencoder \'"+pin+"\' -ovc xvid "+encvf+" -xvidencopts "+bitrate+":threads=2 -oac mp3lame -lameopts cbr:br=128  -o \'"+pout+"\'"
-        pas1exe="nice -n 19 "+pas1exe
+        pas1exe = "mencoder \'" + pin + "\' -ovc xvid " + encvf + " -xvidencopts " + bitrate + ":threads=2 -oac mp3lame -lameopts cbr:br=128  -o \'" + pout + "\'"
+        pas1exe = "nice -n 19 " + pas1exe
         print pas1exe
         commands.getoutput(pas1exe)
         #os.system(pas1exe)