OSDN Git Service

fix encode error.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 14 Mar 2010 03:36:30 +0000 (03:36 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sun, 14 Mar 2010 03:36:30 +0000 (03:36 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@478 4e526526-5e11-4fc0-8910-f8fd03428081

rec10/trunk/src/tv2mkv.py
rec10/trunk/src/tv2mp4.py

index 4ec2880..05db3e2 100644 (file)
@@ -19,7 +19,8 @@ def ts2mkv(pin, pout, opt):
     tpmkv=os.path.join(dir, title+".mkv")
     tv2avi.ts2raw(pin, tpraw, opt)
     time.sleep(10)
-    raw2mkv(tpraw, tpmkv, opt)
+    if os.path.isfile(tpraw) and os.path.getsize(tpraw)>10*1000:
+        raw2mkv(tpraw, tpmkv, opt)
 def raw2mkv(pin,pout,opt):#x264
     dir=os.path.split(pout)[0]
     title=os.path.split(pout)[1]
@@ -40,6 +41,7 @@ def raw2mkv(pin,pout,opt):#x264
         duration="--default-duration 0:30000/1001fps "##ffmpegが24fpsに対応していないための措置
     exe = configreader.getpath("mkvmerge")
     txt=""
+    txt2=""
     os.environ['LANG']="ja_JP.UTF-8"
     if isdualaac==1:
         wineexe=configreader.getpath("wine")
@@ -59,9 +61,9 @@ def raw2mkv(pin,pout,opt):#x264
         if os.path.isfile(cap2ass):
             txt=txt+execcomd(e0)
         if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
-            txt=txt+u"\n Cmd:"+e1s+u"\n"+execcomd(e1s)
+            txt2=txt2+u"\n Cmd:"+e1s+u"\n"+execcomd(e1s)
         else:
-            txt=txt+u"\n Cmd:"+e1+u"\n"+execcomd(e1)
+            txt2=txt2+u"\n Cmd:"+e1+u"\n"+execcomd(e1)
     elif ispentaaudio==1:
         wineexe=configreader.getpath("wine")
         pincap=pin.replace(".264",".srt")
@@ -80,9 +82,9 @@ def raw2mkv(pin,pout,opt):#x264
         if os.path.isfile(cap2ass):
             txt=txt+execcomd(e0)
         if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
-            txt=txt+u"\n Cmd:"+e1s+u"\n"+execcomd(e1s)
+            txt2=txt2+u"\n Cmd:"+e1s+u"\n"+execcomd(e1s)
         else:
-            txt=txt+u"\n Cmd:"+e1+u"\n"+execcomd(e1)
+            txt2=txt2+u"\n Cmd:"+e1+u"\n"+execcomd(e1)
     else:
         wineexe=configreader.getpath("wine")
         pincap=pin.replace(".264",".srt")
@@ -97,93 +99,13 @@ def raw2mkv(pin,pout,opt):#x264
             txt=txt+execcomd(e0)
         txt=txt+execcomd(e1)
         if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
-            txt=txt+u"\n Cmd:"+e2s+"\n"+execcomd(e2s)
+            txt2=txt2+u"\n Cmd:"+e2s+"\n"+execcomd(e2s)
             recdblist.printutf8(e2s)
         else:
-            txt=txt+u"\n Cmd:"+e2+"\n"+execcomd(e2)
+            txt2=txt2+u"\n Cmd:"+e2+"\n"+execcomd(e2)
             recdblist.printutf8(e2)
-    recdblist.addlog(pout, txt, "mkvmerge-log")
-    logo=pout.replace(".mkv",".log")
-    if status.getSettings_auto_del_tmp()==1:
-        if os.path.exists(pout):
-            if os.path.getsize(pout)>100*1000*1000:
-                deltitle(dir,title)
-def avi2mkv(pin,pout,opt):
-    dir=os.path.split(pout)[0]
-    title=os.path.split(pout)[1]
-    title=os.path.splitext(title)[0]
-    isdualaac=0
-    ispentaaudio=0
-    if re.search("d",opt):
-        isdualaac=1
-    elif re.search("5",opt):
-        ispentaaudio=1
-    exe = configreader.getpath("mkvmerge")
-    txt=""
-    txt2=""
-    os.environ['LANG']="ja_JP.UTF-8"
-    if isdualaac==1:
-        wineexe=configreader.getpath("wine")
-        pincap=pin.replace(".avi",".srt")
-        cap2ass=configreader.getpath("Caption2Ass")
-        pints=pin.replace(".avi",".ts")
-        paac1=pin.replace(".avi","_1.aac")
-        paac2=pin.replace(".avi","_2.aac")
-        recdblist.printutf8(paac1)
-        if not os.path.exists(paac1):
-            paac1=pin.replace(".avi","_1.mp3")
-        if not os.path.exists(paac2):
-            paac2=pin.replace(".avi","_2.mp3")
-        e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
-        e1=exe +" -o \""+pout+u"\"  --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --track-order 0:0,1:1,2:1"
-        e1s=exe +" -o \""+pout+u"\"  --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:1,2:1,3:0"
-        if os.path.isfile(cap2ass):
-            txt=txt+execcomd(e0)
-        if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
-            txt2=txt2+execcomd(e1s)
-        else:
-            txt2=txt2+execcomd(e1)
-    elif ispentaaudio==1:
-        wineexe=configreader.getpath("wine")
-        pincap=pin.replace(".avi",".srt")
-        cap2ass=configreader.getpath("Caption2Ass")
-        pints=pin.replace(".avi",".ts")
-        paac1=pin.replace(".avi","_1.aac")
-        paac2=pin.replace(".avi","_2.aac")
-        recdblist.printutf8(paac1)
-        if not os.path.exists(paac1):
-            paac1=pin.replace(".avi","_1.mp3")
-        if not os.path.exists(paac2):
-            paac2=pin.replace(".avi","_2.mp3")
-        e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
-        e1=exe +" -o \""+pout+u"\"  --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --track-order 0:0,1:1,2:1"
-        e1s=exe +" -o \""+pout+u"\"  --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 1 -D -S \""+paac1+"\" --forced-track 0:no -a 1 -D -S \""+paac2+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:1,2:1,3:0"
-        if os.path.isfile(cap2ass):
-            txt=txt+execcomd(e0)
-        if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
-            txt2=txt2+execcomd(e1s)
-        else:
-            txt2=txt2+execcomd(e1)
-    else:
-        wineexe=configreader.getpath("wine")
-        pincap=pin.replace(".avi",".srt")
-        cap2ass=configreader.getpath("Caption2Ass")
-        pints=pin.replace(".avi",".ts")
-        pinaac=pin.replace(".avi",".aac")
-        e0=wineexe+u" "+cap2ass+u" -format srt \"Z:\\"+pints+"\" \"Z:\\"+pincap+"\""
-        e1=ffmpeg+u" -i \""+pints+u"\" -vn -f aac -acodec copy \""+pinaac+"\""
-        e2=exe +" -o \""+pout+u"\"  --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --track-order 0:0,1:0"
-        e2s=exe +" -o \""+pout+u"\"  --forced-track 0:no -d 0 -A -S \""+pin+"\" --sync 0:0 --forced-track 0:no -a 0 -D -S \""+pinaac+"\" --forced-track 0:no -s 0 -D -A \""+pincap+"\" --track-order 0:0,1:0,2:0"
-        if os.path.isfile(cap2ass):
-            txt=txt+execcomd(e0)
-        txt=txt+execcomd(e1)
-        if os.path.exists(pincap) and (os.path.getsize(pincap)>1000):
-            txt2=txt2+execcomd(e2s)
-        else:
-            txt2=txt2+execcomd(e2)
-    recdblist.addlog(pout, txt, "mkvmerge-log-01")
-    recdblist.addlog(pout, txt2, "mkvmerge-log-02")
-    logo=pout.replace(".mkv",".log")
+    recdblist.addlog(pout, txt, "mkvmerge-log1")
+    recdblist.addlog(pout, txt2, "mkvmerge-log2")
     if status.getSettings_auto_del_tmp()==1:
         if os.path.exists(pout):
             if os.path.getsize(pout)>100*1000*1000:
index 5d530f0..5df7ec2 100644 (file)
@@ -23,7 +23,8 @@ def ts2mp4(pin, pout, opt):
     tpmp4=os.path.join(dir, title+".mp4")\r
     tv2avi.ts2raw(pin, tpraw, opt)\r
     time.sleep(10)\r
-    raw2mp4(tpraw, tpmp4, opt)\r
+    if os.path.isfile(tpraw) and os.path.getsize(tpraw)>10*1000:\r
+        raw2mp4(tpraw, tpmp4, opt)\r
 def raw2mp4(pin,pout,opt):\r
     dir=os.path.split(pout)[0]\r
     title=os.path.split(pout)[1]\r
@@ -116,161 +117,6 @@ def raw2mp4(pin,pout,opt):
         if os.path.exists(pout):\r
             if os.path.getsize(pout)>100*1000*1000:\r
                 deltitle(dir,title)\r
-def avi2mp4(pin,pout,opt):\r
-    isvfr=0\r
-    if re.search(u"v", opt):\r
-        isvfr=1\r
-    exe = configreader.getpath(u"MP4Box")\r
-    dir=os.path.split(pin)[0]\r
-    title=os.path.split(pin)[1]\r
-    title=os.path.splitext(title)[0]\r
-    etitle=base64.b16encode(title.encode('utf-8'))\r
-    audiopath=os.path.join(dir,etitle+u"_audio.raw")\r
-    videopath=os.path.join(dir,etitle+u"_video.264")\r
-    exes=[]\r
-    os.environ['LANG']="ja_JP.UTF-8"\r
-    txt=""\r
-    if isvfr==1:\r
-        wineexe=configreader.getpath("wine")\r
-        cfr2tc=configreader.getpath("cfr2tc")\r
-        dtsedit=configreader.getpath("DtsEdit")\r
-        caption2ass=configreader.getpath("Caption2Ass")\r
-        pin120=os.path.join(dir,etitle+u".120.avi")\r
-        pints=os.path.join(dir,title+u".ts")\r
-        pmp4=os.path.join(dir,etitle+u".tmp.mp4")\r
-        pintimecode=os.path.join(dir,etitle+u".timecode.txt")\r
-        pinaac=os.path.join(dir,etitle+u".aac")\r
-        pincat=os.path.join(dir,etitle+u".srt")\r
-        evfr0=ffmpeg+u" -i '"+pints+"' -vn -f aac -acodec copy '"+pinaac+"'"\r
-        evfr1=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+pin+"' '"+"Z:\\"+pin120+u"' 'Z:\\"+pintimecode+u"' 2"\r
-        evfr2=exe+u" -aviraw video \'"+pin120+u"\'"\r
-        videotpath=os.path.join(dir,etitle+u".120_video.h264")\r
-        evfr3=exe+u" -fps 29.970030 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"\r
-        evfr4=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'"\r
-        try:\r
-            recdblist.printutf8(evfr0)\r
-            txt=txt+evfr0+"\n"\r
-            txt=txt+unicode(commands.getoutput(evfr0.encode('utf-8')),'utf-8')\r
-        except:\r
-            ""\r
-        try:\r
-            recdblist.printutf8(evfr1)\r
-            txt=txt+evfr1+"\n"\r
-            txt=txt+unicode(commands.getoutput(evfr1.encode('utf-8')),'utf-8')\r
-        except:\r
-            ""\r
-        try:\r
-            if not os.path.exists(pin120):\r
-                evfr2=exe+u" -aviraw video \'"+pin+u"\'"\r
-                videotpath=os.path.join(dir,etitle+u"_video.h264")\r
-                evfr3=exe+u" -fps 29.970030 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"\r
-            recdblist.printutf8(evfr2)\r
-            txt=txt+evfr2+"\n"\r
-            txt=txt+unicode(commands.getoutput(evfr2.encode('utf-8')),'utf-8')\r
-        except:\r
-            ""\r
-        try:\r
-            recdblist.printutf8(evfr3)\r
-            txt=txt+evfr3+"\n"\r
-            txt=txt+unicode(commands.getoutput(evfr3.encode('utf-8')),'utf-8')\r
-        except:\r
-            ""\r
-        try:\r
-            recdblist.printutf8(evfr4)\r
-            txt=txt+evfr4+"\n"\r
-            txt=txt+unicode(commands.getoutput(evfr4.encode('utf-8')),'utf-8')\r
-        except:\r
-            ""\r
-        if (not os.path.exists(pin.replace(".avi",".120.avi"))and (not os.path.exists(pout))):\r
-            txt=txt+"CFR2TC error. maybe avi file is over 1GB.(ODML error would have happened.)"\r
-            ptmp=pin.replace(".avi",".noodml.avi")\r
-            e="mencoder -noodml -forceidx -oac copy -ovc copy -o \'"+ptmp+"\'"+" \'"+pin+"\'"\r
-            ex="nice -n 17 "+e\r
-            e2=wineexe+u" "+cfr2tc+u" '"+"Z:\\"+ptmp+"' '"+"Z:\\"+pin120+u"' '"+"Z:\\"+pintimecode+u"' 2"\r
-            ex2="nice -n 17 "+e2\r
-            e3=exe+u" -aviraw video \'"+pin120+u"\'"\r
-            ex3="nice -n 17 "+e3\r
-            e4=exe+u" -fps 29.97 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"\r
-            ex4="nice -n 17 "+e4\r
-            e5=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'"\r
-            ex5="nice -n 17 "+e5\r
-            recdblist.printutf8(e)\r
-            txt=txt+e+"\n"\r
-            try:\r
-                cmdt=unicode(commands.getoutput(ex.encode('utf-8')),'utf-8')\r
-            except:\r
-                ""\r
-            try:\r
-                cmdt=unicode(commands.getoutput(ex2.encode('utf-8')),'utf-8')\r
-            except:\r
-                ""\r
-            try:\r
-                if os.path.exists(pin120):\r
-                    cmdt=unicode(commands.getoutput(ex3.encode('utf-8')),'utf-8')\r
-            except:\r
-                ""\r
-            try:\r
-                cmdt=unicode(commands.getoutput(ex4.encode('utf-8')),'utf-8')\r
-            except:\r
-                ""\r
-            try:\r
-                cmdt=unicode(commands.getoutput(ex5.encode('utf-8')),'utf-8')\r
-            except:\r
-                ""\r
-            try:\r
-                os.remove(ptmp)\r
-            except:\r
-                ""\r
-            txt=txt+cmdt+"\n"\r
-    else:\r
-        try:\r
-            shutil.move(pin,os.path.join(dir,etitle+".avi"))\r
-        except:\r
-            ""\r
-        if os.path.exists(os.path.join(dir,etitle+".avi")):\r
-            e0=exe+u" -aviraw audio \'"+os.path.join(dir,etitle+".avi")+u"\'"\r
-            e1=exe+u" -aviraw video \'"+os.path.join(dir,etitle+".avi")+u"\'"\r
-            os.system(e0)\r
-            os.system(e1)\r
-        if not os.path.exists(audiopath):\r
-            if os.path.exists(os.path.join(dir,etitle+u"_audio.mp3")):\r
-                audiopath=os.path.join(dir,etitle+u"_audio.mp3")\r
-            elif os.path.exists(os.path.join(dir,etitle+u"_audio.aac")):\r
-                audiopath=os.path.join(dir,etitle+u"_audio.aac")\r
-        else:\r
-            shutil.move(audiopath,os.path.join(dir,etitle+u"_audio.aac"))\r
-            audiopath=os.path.join(dir,etitle+u"_audio.aac")\r
-        ptmp=os.path.exists(os.path.join(dir,etitle+u".mp4"))\r
-        e2=exe+u" -fps 29.970030 -add \'"+videopath+u"\' -add \'"+audiopath+u"\' -new \'"+ptmp+u"\'"\r
-        os.system(e2)\r
-        shutil.move(ptmp,pout)\r
-    recdblist.addlog(pin,txt,"MP4Box-log")\r
-    time.sleep(10)\r
-    delpath=[]\r
-    delpath.append(pin.replace(u".avi",u".120.avi"))\r
-    delpath.append(pin.replace(u".avi",u".sa.avi"))\r
-    delpath.append(pin.replace(u".avi",u".m2v"))\r
-    delpath.append(pin.replace(u".avi",u"_1.aac"))\r
-    delpath.append(pin.replace(u".avi",u"_2.aac"))\r
-    delpath.append(pin.replace(u".avi",u"_1.mp3"))\r
-    delpath.append(pin.replace(u".avi",u"_2.mp3"))\r
-    delpath.append(pin.replace(u".avi",u".ts"))\r
-    delpath.append(pin.replace(u".avi",u".aac"))\r
-    delpath.append(pin.replace(u".avi",u".m2v"))\r
-    delpath.append(pin.replace(u".avi",u".120_video.264"))\r
-    delpath.append(pin.replace(u".avi",u".ts.b25"))\r
-    if os.path.exists(pout):\r
-        if os.path.exists(audiopath):\r
-            os.remove(audiopath)\r
-        if os.path.exists(videopath):\r
-            os.remove(videopath)\r
-        """\r
-        for dp in delpath:\r
-            try:\r
-                os.remove(dp)\r
-            except:\r
-                ""\r
-        """\r
 def mkv2mp4(pin,pout):\r
     exeb = configreader.getpath(u"mkvextract")\r
     exe = configreader.getpath(u"MP4Box")\r