OSDN Git Service

implement videoframe compliment option.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 24 Oct 2010 03:15:31 +0000 (03:15 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 24 Oct 2010 03:15:31 +0000 (03:15 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@695 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/tv2audio.py
rec10/trunk/src/tv2mp4.py

index 5617e6c..8edf22a 100644 (file)
@@ -161,3 +161,120 @@ def ts2single_mp3_BonTsDemux(pts,opts):
     aout=pts.replace(".ts",".mp3")
     ain=pts.replace(".ts",".wav")
     tv2audio.wav2mp3_lame(ain,aout)
+def dualaudio2sep(pin, delay,opts):
+    """
+    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:]
+    if re.search(",",opts):
+        vf="-vf "
+    exe = wine + ' ' + bontsdemux + " -i \"" + bonpin + "\" -delay " + delay + " -nd "+vf+"-sound 1 -o \"" + bonpout + "\" -start -quit"
+    recdblist.printutf8(exe)
+    exe = xvfb + ' -a ' + exe
+    txt=commands.getoutput(exe.encode('utf-8'))
+    try:
+        recdblist.addCommandLog(pin, u"BonTsDemux 第一音声取り出し", exe, txt)
+    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  "+vf+"-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.addCommandLog(pin, u"BonTsDemux 第二音声取り出し", exe, txt)
+    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.addCommandLog(pin, u"BonTsDemux5.1ch 第一音声取り出し", exe, txt)
+    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.addCommandLog(pin, u"FFmpeg 5.1ch 第二音声(raw AAC)取り出し", exe, txt)
+    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.addCommandLog(pin, u"BonTsDemux 修正版第二音声(2chDownmix)取り出し", exe, txt)
+        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)
\ No newline at end of file
index f46dce2..ce41189 100644 (file)
@@ -26,6 +26,11 @@ def ts2mp4(pin, pout, opt):
     title=os.path.splitext(title)[0]\r
     tpraw=os.path.join(dir, title+".264")\r
     tpmp4=os.path.join(dir, title+".mp4")\r
+    if re.search("x",opt) or re.search("b",opt):\r
+        if re.search(".",opts):\r
+            tv2audio.dualaudio2sep(pin, 0, opt)\r
+        else:\r
+            tv2audio.dualaudio2sep(pin, 167, opt)\r
     if os.path.isfile(pin) and os.path.getsize(pin)>10*1000:\r
         tv2avi.ts2raw(pin, tpraw, opt)\r
         time.sleep(10)\r