#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:
import os
import shutil
import time
+import os.path
+
import chdb
import n_gram
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
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()
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:
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:
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":
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)
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')
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")
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]
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'))
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:
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 #"
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]
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]
elif chcode>=0x30A0 and chcode<=0x30FF:
return 3
elif chcode>=0x4E00 and chcode<=0x9FFF:
- return 4
\ No newline at end of file
+ return 4