OSDN Git Service

fix many bug.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Fri, 18 Dec 2009 00:19:07 +0000 (00:19 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Fri, 18 Dec 2009 00:19:07 +0000 (00:19 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@312 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/classify.py
rec10/trunk/src/epgdb.py
rec10/trunk/src/timerec.py
rec10/trunk/src/ts2x264.py
rec10/trunk/src/tv2mkv.py
rec10/trunk/src/tv2mp4.py
rec10/trunk/src/xml2db_dom.py
rec10/trunk/src/zenhan.py

index 92991b4..56725ff 100644 (file)
@@ -111,7 +111,7 @@ def veryfySize(path):
     #vsize=[297,497,596,1196]#SD 30m 1h 1.5h 2h
     vsize=[245,275,295,591,830]
     vsize=vsize+[325,449,560,590,602,690,805,860,1014,1138,1237]
-    #vsize=vsize+[458,916]#HD 30m 1h
+    vsize=vsize+[261,535,540,616,740]#HD 30m 1h
     #vsize=vsize+[381,895,447]
     ret = 0
     for size in vsize:
index 7479192..83a4b6c 100644 (file)
@@ -6,6 +6,8 @@ import datetime
 import os
 import shutil
 import time
+import os.path
+
 
 import chdb
 import n_gram
@@ -28,8 +30,8 @@ def update(chtxt):
     dt = tnow-lastup
     dt = dt.days * 24 * 60 + dt.seconds
     if dt > 2 * 60 * 60:
-        ts2epg.write(tmppath + chtxt + "epgdata.xml", chdb.chtxtsearch(chtxt)['ch'])
-        xml2db_dom.xml2db_dom(tmppath + chtxt + "epgdata.xml", chdb.chtxtsearch(chtxt)['bctype'])
+        ts2epg.write(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.chtxtsearch(chtxt)['ch'])
+        xml2db_dom.xml2db_dom(os.path.join(tmppath, chtxt + "epgdata.xml"), chdb.chtxtsearch(chtxt)['bctype'])
 def updatebc(bctype):
     bctypel = chdb.bctypesearch(bctype)
     print bctype
index b4465a8..76b02f4 100644 (file)
@@ -175,6 +175,7 @@ def task():
                 else:
                     recdb.del_reckey(recdblist.REC_AVI_TO_MKV, title, chtxt, btime)
                     recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
+                    #tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"),opt)
                     tv2mkv.avi2mkv(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mkv"),opt)
                     recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
                     sys.exit()
@@ -186,7 +187,7 @@ def task():
                 else:
                     recdb.del_reckey(recdblist.REC_AVI_TO_MP4, title, chtxt, btime)
                     recdb.rec_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime, etime, opt)
-                    tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mp4"))
+                    tv2mp4.avi2mp4(os.path.join(recpath,title+".avi"),os.path.join(recpath,title+".mp4"),opt)
                     recdb.del_reckey(recdblist.REC_CHANGING_CANTAINER, title, chtxt, btime)
                     sys.exit()
         elif task["type"] == recdblist.REC_MKV_TO_MP4:
@@ -319,7 +320,7 @@ def type_final(typetxt,chtxt,title,bt,et,opt):
         testpath=[os.path.join(recpath,title+".ts.b25")]
         testpath.append(os.path.join(recpath,title+".ts"))
         testpath.append(os.path.join(recpath,title+".avi"))
-        testpath.append(os.path.join(recpath,title+".mkv"))
+        testpath.append(os.path.join(recpath,title+".mp4"))
         testpath.append(os.path.join(recpath,title+".log"))
         tcheck=0
         for ti in testpath:
index d9a1975..5356fc2 100644 (file)
@@ -49,19 +49,19 @@ def encode(pin,pout,size,isvfr,is2pass):
         ofps="-ofps 120000/1001"
         encvf="-vf pullup,softskip,pp=mb"
         bm=4
-        x264enc1=":me=hex"
-        x264enc2=":frameref=3:subq=7:partitions=all:8x8dct:me=umh:bframes=3:weight_b"
+        x264enc1=":me=hex:bframes=3"
+        x264enc2=":frameref=3:subq=7:partitions=all:8x8dct:direct=auto:me=umh:bframes=3:weight_b"
         harddup=""
     if size == "HD":
-        encvf = encvf + ",scale=1280:720:::4"+harddup
+        encvf = encvf + ",scale=1280:720::0:4"+harddup
         bitrate = "bitrate=" + str(tv2avi.Bitrate_HD*bm)
         crf="crf=20"
     elif size == "SD":
-        encvf = encvf + ",scale=720:480:::4"+harddup
+        encvf = encvf + ",scale=720:480::0:4"+harddup
         bitrate = "bitrate=" + str(tv2avi.Bitrate_SD*bm)
         crf="crf=20"
     elif size == "FHD":
-        encvf = encvf + ",scale=1920:1080:::4"+harddup
+        encvf = encvf + ",scale=1920:1080::0:4"+harddup
         bitrate = "bitrate=" + str(tv2avi.Bitrate_FHD*bm)
         crf="crf=22"
     elif size == "Short":
@@ -69,16 +69,16 @@ def encode(pin,pout,size,isvfr,is2pass):
         bitrate = "bitrate=" + str(tv2avi.Bitrate_Short*bm)
         crf="crf=20"
     elif size == "LowHD":
-        encvf = encvf + ",scale=1280:720:::4"+harddup
+        encvf = encvf + ",scale=1280:720::0:4"+harddup
         bitrate = "bitrate=" + str(tv2avi.Bitrate_LowHD*bm)
         crf="crf=22"
     else:
-        encvf = encvf + ",scale=1280:720:::4"+harddup
+        encvf = encvf + ",scale=1280:720::0:4"+harddup
         bitrate = "bitrate=" + str(tv2avi.Bitrate_HD*bm)
         crf="crf=22"
     if is2pass == 1:
-        pas1exe = "mencoder \'" + pin + "\' -quiet -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc1+ ":threads=auto:pass=1:turbo=2 -passlogfile \'" + pin + ".log\' " + "-oac faac -o /dev/null"
-        pas2exe = "mencoder \'" + pin + "\' -quiet -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc2+ ":threads=auto:pass=2 -passlogfile \'" + pin + ".log\' " + "-oac faac -o \'" + pout + "\'"
+        pas1exe = "mencoder \'" + pin + "\' -noskip -quiet -nosound -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc1+ ":threads=auto:pass=1:turbo=2 -passlogfile \'" + pin + ".log\' " + " -o /dev/null"
+        pas2exe = "mencoder \'" + pin + "\' -noskip -noodml -quiet -nosound -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc2+ ":threads=auto:pass=2 -passlogfile \'" + pin + ".log\' " + " -o \'" + pout + "\'"
         pas1exe = "nice -n 19 " + pas1exe
         pas2exe = "nice -n 19 " + pas2exe
         recdblist.printutf8(pas1exe)
@@ -87,7 +87,7 @@ def encode(pin,pout,size,isvfr,is2pass):
         time.sleep(5)
         txt=txt+unicode(commands.getoutput(pas2exe.encode('utf-8')),'utf-8')
     else:
-        pas1exe = "mencoder \'" + pin + "\' -quiet -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc2+":threads=auto -oac faac -o \'" + pout + "\'"
+        pas1exe = "mencoder \'" + pin + "\' -noskip -noodml -nosound -quiet -sws 9 -ovc x264 " + encvf + " "+ofps+" -x264encopts " + bitrate +x264enc2+":threads=auto -o \'" + pout + "\'"
         pas1exe = "nice -n 19 " + pas1exe
         recdblist.printutf8(pas1exe)
         txt=txt+unicode(commands.getoutput(pas1exe.encode('utf-8')),'utf-8')
index 44f3503..3c2899e 100644 (file)
@@ -40,9 +40,12 @@ def avi2mkv(pin,pout,opt):
         pinaac=pin.replace(".avi",".aac")
         ffmpegdo="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"
         doexe0 = wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"
-        doexe = exe +" -o '"+pout+"'  --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-250 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
+        doexe = exe +" -o '"+pout+u"'  --forced-track 0:no --timecodes '0:"+pintimecode+"' -d 0 -A -S '"+pin120+"' --sync 0:-225 --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
     else:
-        doexe = exe + u" -o '" + pout + u"' --cues 0:all --forced-track 0:no --forced-track 1:no -a 1 -d 0 -S '" + pin + u"' --track-order 0:0,0:1"
+        pinaac=pin.replace(".avi",".aac")
+        pints=pin.replace(".avi",".ts")
+        ffmpegdo="ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"
+        doexe = exe + u" -o '" + pout + u"' --forced-track 0:no --default-duration 0:30000/1001fps -d 0 -A -S '" + pin + u"' --forced-track 0:no -a 0 -D -S '"+pinaac+"' --track-order 0:0,1:0"
     doexe = "nice -n 17 " + doexe
     recdblist.printutf8(doexe)
     logo=pout.replace(".mkv",".log")
index 3f67be2..1a28d31 100644 (file)
@@ -6,9 +6,12 @@ import sys
 import commands
 import tv2avi
 import os
+import re
 import os.path
 import time
+import recdblist
 import configreader
+
 def ts2mp4(pin, pout, opt):
     dir=os.path.split(pout)[0]
     title=os.path.split(pout)[1]
@@ -19,31 +22,51 @@ def ts2mp4(pin, pout, opt):
     if not os.path.exists(tpavi):
         if os.path.exists(pin):
             tpavi=pin
-    isvfr=0
-    if re.search("v", opt):
+    avi2mp4(tpavi,pout,opt)
+def avi2mp4(pin,pout,opt):
+    if re.search(u"v", opt):
         isvfr=1
-    avi2mp4(tpavi,pout,isvfr)
-def avi2mp4(pin,pout,isvfr):
     exe = configreader.getpath(u"MP4Box")
     dir=os.path.split(pin)[0]
     title=os.path.split(pin)[1]
     title=os.path.splitext(title)[0]
-    audiopath=os.path.join(dir,title+u"_audio.mp3")
+    audiopath=os.path.join(dir,title+u"_audio.raw")
     videopath=os.path.join(dir,title+u"_video.h264")
+    exes=[]
+    exes.append(exe+u" -aviraw audio \'"+pin+u"\'")
+    exes.append(exe+u" -aviraw video \'"+pin+u"\'")
+    exes.append(exe+u" -new -fps 29.97 -add \'"+videopath+u"\'#video -add \'"+audiopath+u"\'#audio \'"+pout+u"\'")
     if isvfr==1:
-        ""
-    #doexe = exe.encode('utf-8') + u' \"' + pin.encode('utf-8') + u'\" \"' + pout.encode('utf-8') + u'\"'
-    exe1=exe+u" -aviraw audio \'"+pin+u"\'"
-    exe2=exe+u" -aviraw video \'"+pin+u"\'"
-    exefin=exe+u" -new -fps 29.97 -add \'"+videopath+u"\'#video -add \'"+audiopath+u"\'#audio \'"+pout+u"\'"
+        exes=[]
+        wineexe=configreader.getpath("wine")
+        cfr2tc=configreader.getpath("cfr2tc")
+        dtsedit=configreader.getpath("DtsEdit")
+        pin120=pin.replace(".avi",".120.avi")
+        pints=pin.replace(".avi",".ts")
+        pmp4=pin.replace(".avi",".tmp.mp4")
+        pintimecode=pin.replace(".avi",".timecode.txt")
+        pinaac=pin.replace(".avi",".aac")
+        evfr=[]
+        evfr.append("ffmpeg -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'")
+        evfr.append(wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' 'Z:\\"+pintimecode+u"' 2")
+        evfr.append(exe+u" -aviraw video \'"+pin120+u"\'")
+        videotpath=os.path.join(dir,title+u".120_video.h264")
+        evfr.append(exe+u" -fps 29.97 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'")
+        #evfr.append(exe+u" -add \'"+pinaac+"\' \'"+pmp4+"\'")
+        evfr.append(wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'")
+        
+        exes=evfr
     logo=pin.replace(u".avi",u".log")
     os.environ['LANG']="ja_JP.UTF-8"
-    txt= exe1+u"\n"+exe2+u"\n"+exefin+u"\n"
-    txt = txt+unicode(commands.getoutput(exe1.encode('utf-8')),'utf-8')
-    txt = txt+unicode(commands.getoutput(exe2.encode('utf-8')),'utf-8')
-    txt = txt+unicode(commands.getoutput(exefin.encode('utf-8')),'utf-8')
-    os.remove(audiopath)
-    os.remove(videopath)
+    txt=""
+    print exes
+    for e in exes:
+        recdblist.printutf8(e)
+        txt=txt+e+"\n"
+        try:
+            txt=txt+unicode(commands.getoutput(e.encode('utf-8')),'utf-8')
+        except:
+            ""
     txt = "\n####MP4Box-log####\n"+txt
     f=open(logo,'a')
     f.write(txt.encode('utf-8'))
index 793c48c..46585b0 100644 (file)
@@ -74,7 +74,7 @@ def xml2db_dom(xmlpath, bctype):#bctypeは放送種別で'TE'(地デジ)BS,CSが
                             p2t=n_gram.trigram(ch['title'],title)
                             if p2t>p2:
                                 p2=p2t
-                    if p2<400:
+                    if p2<350:
                         recdb.add_auto_bayes(tch['chtxt'],title,start,stop,p)
     dom.unlink()
     if len(chlist) > 0:
index d5650a1..6fe4651 100644 (file)
@@ -8,8 +8,12 @@ global z_ascii
 global h_ascii
 global z_number
 global h_number
-z_ascii = u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !”#$%&’()*+,−./:;<=>?@[¥]^_‘{|}〜 ."
-h_ascii = u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ."
+z_ascii = u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !”#$%&’()*+,−./:;<=>?@[¥]^_‘{|}〜 "
+h_ascii = u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ "
+#z_ascii = z_ascii+Ur"\Ue28892\Uefbc8e"
+#h_ascii = h_ascii+Ur"\Uefbc8d."
+z_ascii_sp = unichr(0x2212)+unichr(0xff0e)
+h_ascii_sp = unichr(0x002d)+unichr(0x002e)
 z_number = u"0123456789"
 h_number = u"0123456789"
 z_alphabet = u"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #"
@@ -20,6 +24,9 @@ def toHankaku(str):
         i = z_ascii.find(s)
         if (i != -1):
             s = h_ascii[i]
+        i = z_ascii_sp.find(s)
+        if (i != -1):
+            s = h_ascii_sp[i]
         i = z_number.find(s)
         if (i != -1):
             s = h_number[i]
@@ -31,6 +38,9 @@ def toHankaku_ABC123(str):
         i = z_alphabet.find(s)
         if (i != -1):
             s = h_alphabet[i]
+        i = z_ascii_sp.find(s)
+        if (i != -1):
+            s = h_ascii_sp[i]
         i = z_number.find(s)
         if (i != -1):
             s = h_number[i]
@@ -54,4 +64,4 @@ def check_Character_Type(character):
     elif chcode>=0x30A0 and chcode<=0x30FF:
         return 3
     elif chcode>=0x4E00 and chcode<=0x9FFF:
-        return 4
\ No newline at end of file
+        return 4