OSDN Git Service

stop using trunk directory in rectool
[rec10/rec10-git.git] / rec10 / trunk / src / tv2avi.py
index e76c190..f441bee 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 # coding: UTF-8
 # Rec10 TS Recording Tools
-# Copyright (C) 2009-2010 Yukikaze
+# Copyright (C) 2009-2011 Yukikaze
 import commands
 import datetime
 import os
@@ -9,6 +9,7 @@ import re
 import shutil
 import time
 import os.path
+import traceback
 
 import chdb
 import configreader
@@ -46,7 +47,7 @@ def timetv2b25(pout, chtxt, btime, etime, opt):
     dt = et-tnow
     rectime = dt.seconds-5
     rectime = str(rectime)
-    tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.chtxtsearch(chtxt)['ch'], rectime)
+    tv2ts.tv2b25ts(tsout + ".ts.b25", chdb.searchCHFromChtxt(chtxt)['ch'], rectime,chdb.searchCHFromChtxt(chtxt)['tsid'])
 def b252ts(pout, chtxt, btime, etime, opt):
     """
     poutはタイトル(自動的にtitle.b25 title.tsと名前がつきます。)
@@ -54,7 +55,15 @@ def b252ts(pout, chtxt, btime, etime, opt):
     #status.setB25Decoding(status.getB25Decoding() + 1)
     status.changeB25Decoding(1)
     try:
-        tv2ts.b252ts(pout + ".ts", chdb.chtxtsearch(chtxt)['ch'], chdb.chtxtsearch(chtxt)['csch'])
+        try:
+            chs=chdb.searchCHFromChtxt(chtxt)
+            ch=chs['ch']
+            csch=chs['csch']
+            #print [ch,csch,chtxt]
+        except:
+            ch="0"
+            csch="0"
+        tv2ts.b252ts(pout + ".ts", ch, csch)
         tsout = pout
         aviin = pout + ".ts"
         dualaudio = 0
@@ -64,24 +73,22 @@ def b252ts(pout, chtxt, btime, etime, opt):
             pentaaudio = 1
         if re.search("d", opt):
             dualaudio = 1
+        if re.search("b", opt):
+            singleaudiosplit = 1
         if re.search(u"\[二\]", pout):
             dualaudio = 1
         elif re.search(u'(二)', pout):
             dualaudio = 1
         elif re.search(u'\(二\)', pout):
             dualaudio = 1
-        elif re.search("b",opt):
-            singleaudiosplit = 1
         if dualaudio == 1:
-            dualaudio2sep(aviin,"167")
+            tv2audio.ts2dualaudio_BonTsDemux(aviin, recdblist.BONTSDEMUX_DELAY, opt)
         if pentaaudio == 1:
-            pentaaudio2sep(aviin)
-        if singleaudiosplit ==1:
-            singleaudio2sep(aviin)
+            tv2audio.ts2pentaaudio_BonTsDemux(aviin, recdblist.BONTSDEMUX_DELAY, opt)
+        if singleaudiosplit == 1:
+            tv2audio.ts2single_fp_BonTsDemux(aviin, opt)
     except Exception, inst:
-        recdblist.printutf8("Error happened in b252ts in tv2avi")
-        recdblist.printutf8(str(type(inst)))
-        recdblist.printutf8(str(inst))
+        recdblist.addCommonlogEX("Error", "b252ts(tv2avi.py)", str(type(inst))+traceback.format_exc(), str(inst))
     status.changeB25Decoding(-1)
 def ts2avi(pin, pout, opt):
     status.changeEncoding(1)
@@ -90,7 +97,7 @@ def ts2avi(pin, pout, opt):
     except Exception, inst:
         recdblist.printutf8("error occures in tv2avi.py ts2avi")
         recdblist.printutf8(str(type(inst)))
-        recdblist.printutf8(str(inst))
+        recdblist.printutf8(str(inst)+traceback.format_exc())
     status.changeEncoding(-1)
 def ts2raw(pin, pout, opt):
     status.changeEncoding(1)
@@ -99,165 +106,6 @@ def ts2raw(pin, pout, opt):
     except Exception, inst:
         recdblist.printutf8("error occures in tv2avi.py ts2raw")
         recdblist.printutf8(str(type(inst)))
-        recdblist.printutf8(str(inst))
+        recdblist.printutf8(str(inst)+traceback.format_exc())
     status.changeEncoding(-1)
-def dualaudio2sep(pin, delay):
-    """
-    delay is string
-    """
-    xvfb = configreader.getpath('xvfb-run')
-    bontsdemux = configreader.getpath('bontsdemux')
-    wine = configreader.getpath('wine')
-    bonpin = "Z:\\" + pin[1:]
-    outf = os.path.splitext(pin)[0]
-    bonpout = "Z:\\" + outf[1:]
-    exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 1 -o \"" + bonpout + "\" -start -quit"
-    recdblist.printutf8(exe)
-    exe = xvfb + ' -a ' + exe
-    txt=commands.getoutput(exe.encode('utf-8'))
-    try:
-        recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
-    except:
-        ""
-    ffpin = pin.replace(".ts", "")
-    ffpin1 = pin.replace("ts", "wav")
-    ffpin2 = pin.replace("ts", "m2v")
-    ffpout1 = ffpin + "_1.wav"
-    ffpout2 = ffpin + "_2.wav"
-    ffpout3 = ffpin + ".m2v"
-    shutil.move(ffpin1, ffpout1)
-    exe = 'wine ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd -sound 2 -encode Demux\(wav\) -o \"" + bonpout + "\" -start -quit"
-    recdblist.printutf8(exe)
-    exe = xvfb + ' -a ' + exe
-    txt=commands.getoutput(exe.encode('utf-8'))
-    try:
-        recdblist.addlog(pin, txt, "dualaudio-sep1 BontsDemux")
-    except:
-        ""
-    #os.system(exe)
-    shutil.move(ffpin1, ffpout2)
-    shutil.move(ffpin2, ffpout3)
-    ffpout21=ffpout1.replace(".wav",".mp3")
-    ffpout22=ffpout2.replace(".wav",".mp3")
-    useNero=0
-    try:
-        if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
-            useNero=1
-    except:
-        useNero=0
-    if useNero==1:
-        ffpout21=ffpout1.replace(".wav",".aac")
-        ffpout22=ffpout2.replace(".wav",".aac")
-        tv2audio.wav2aac_nero(ffpout1, ffpout21)
-        tv2audio.wav2aac_nero(ffpout2, ffpout22)
-    else:
-        tv2audio.wav2mp3_lame(ffpout1, ffpout21)
-        tv2audio.wav2mp3_lame(ffpout2, ffpout22)
-    time.sleep(3)
-    os.remove(ffpout1)
-    os.remove(ffpout2)
-def pentaaudio2sep(pin):
-    bontsdemux = configreader.getpath('bontsdemux')
-    wine = configreader.getpath('wine')
-    xvfb = configreader.getpath('xvfb-run')
-    bonpin = "Z:\\" + pin[1:]
-    outf = os.path.splitext(pin)[0]
-    bonpout = "Z:\\" + outf[1:]
-    exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 3 -o \"" + bonpout + "\" -start -quit"
-    exe = xvfb + ' -a ' + exe
-    recdblist.printutf8(exe)
-    txt=commands.getoutput(exe.encode('utf-8'))
-    try:
-        recdblist.addlog(pin, txt, "pentaaudio-sep1 BontsDemux")
-    except:
-        ""
-    ffpin = pin.replace(".ts", "")
-    ffpin1 = pin.replace("ts", "wav")
-    ffpin2 = pin.replace("ts", "m2v")
-    ffpout1 = ffpin + "_1.wav"
-    ffpout2 = ffpin + "_2.aac"
-    shutil.move(ffpin1, ffpout1)
-    exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
-    recdblist.printutf8(exe)
-    txt=commands.getoutput(exe.encode('utf-8'))
-    try:
-        recdblist.addlog(pin, txt, "pentaaudio-sep2(raw aac) ffmpeg")
-    except:
-        ""
-    ffpout21=ffpout1.replace(".wav",".mp3")
-    useNero=0
-    try:
-        if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
-            useNero=1
-    except:
-        useNero=0
-    if useNero==1:
-        ffpout21=ffpout1.replace(".wav",".aac")
-        tv2audio.wav2aac_nero(ffpout1, ffpout21)
-    else:
-        tv2audio.wav2mp3_lame(ffpout1, ffpout21)
-    if not os.path.exists(ffpout21):
-        exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
-        exe = xvfb + ' -a ' + exe
-        recdblist.printutf8(exe)
-        txt=commands.getoutput(exe.encode('utf-8'))
-        try:
-            recdblist.addlog(pin, txt, "pentaaudio-sep Downmix (5.1ch error) BontsDemux")
-        except:
-            ""
-        shutil.move(ffpin1, ffpout1)
-        if useNero==1:
-            ffpout21=ffpout1.replace(".wav",".aac")
-            tv2audio.wav2aac_nero(ffpout1, ffpout21)
-        else:
-            tv2audio.wav2mp3_lame(ffpout1, ffpout21)
-        time.sleep(3)
-    ffpout21=ffpout1.replace(".wav",".aac")
-    if os.path.exists(ffpout21):
-        if os.path.getsize(ffpout21)>10*1000*1000:
-            os.remove(ffpout1)
 
-def singleaudio2sep(pin):
-    bontsdemux = configreader.getpath('bontsdemux')
-    wine = configreader.getpath('wine')
-    xvfb = configreader.getpath('xvfb-run')
-    bonpin = "Z:\\" + pin[1:]
-    outf = os.path.splitext(pin)[0]
-    bonpout = "Z:\\" + outf[1:]
-    exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay 167 -nd -sound 0 -o \"" + bonpout + "\" -start -quit"
-    exe = xvfb + ' -a ' + exe
-    recdblist.printutf8(exe)
-    txt=commands.getoutput(exe.encode('utf-8'))
-    try:
-        recdblist.addlog(pin, txt, "singleaaudio-sep1 BontsDemux")
-    except:
-        ""
-    ffpin = pin.replace(".ts", "")
-    ffpin1 = pin.replace("ts", "wav")
-    ffpin2 = pin.replace("ts", "m2v")
-    ffpout1 = ffpin + "_1.wav"
-    ffpout2 = ffpin + "_2.aac"
-    shutil.move(ffpin1, ffpout1)
-    exe = "ffmpeg -i '"+pin+"' -vn -f aac -acodec copy '"+ffpout2+"'"
-    recdblist.printutf8(exe)
-    txt=commands.getoutput(exe.encode('utf-8'))
-    try:
-        recdblist.addlog(pin, txt, "singleaudio-sep2(raw aac) ffmpeg")
-    except:
-        ""
-    ffpout21=ffpout1.replace(".wav",".mp3")
-    useNero=0
-    try:
-        if configreader.getpath("useNeroAAC")=="1" and os.path.exists(configreader.getpath("NeroAAC")):
-            useNero=1
-    except:
-        useNero=0
-    if useNero==1:
-        ffpout21=ffpout1.replace(".wav",".aac")
-        tv2audio.wav2aac_nero(ffpout1, ffpout21)
-    else:
-        tv2audio.wav2mp3_lame(ffpout1, ffpout21)
-    ffpout21=ffpout1.replace(".wav",".aac")
-    if os.path.exists(ffpout21):
-        if os.path.getsize(ffpout21)>10*1000*1000:
-            os.remove(ffpout1)
\ No newline at end of file