OSDN Git Service

fix mp4 vfr.
[rec10/rec10-git.git] / rec10 / trunk / src / tv2mp4.py
index 3eb39ca..25c11bc 100644 (file)
@@ -32,7 +32,7 @@ def avi2mp4(pin,pout,opt):
     dir=os.path.split(pin)[0]
     title=os.path.split(pin)[1]
     title=os.path.splitext(title)[0]
-    etitle=base64.b16encode(title)
+    etitle=base64.b16encode(title.encode('utf-8'))
     audiopath=os.path.join(dir,etitle+u"_audio.raw")
     videopath=os.path.join(dir,etitle+u"_video.264")
     exes=[]
@@ -45,17 +45,15 @@ def avi2mp4(pin,pout,opt):
         pin120=os.path.join(dir,etitle+u".120.avi")
         pints=os.path.join(dir,title+u".ts")
         pmp4=os.path.join(dir,etitle+u".tmp.mp4")
-        pmp42=os.path.join(dir,etitle+u".tmp2.mp4")
         pintimecode=os.path.join(dir,etitle+u".timecode.txt")
         pinaac=os.path.join(dir,etitle+u".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,etitle+u".120_video.264")
+        videotpath=os.path.join(dir,etitle+u".120_video.h264")
         evfr.append(exe+u" -fps 29.970030 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'")
-        evfr.append(wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pmp42+"\'")
-        evfr.append(exe+u" -add \'"+pinaac+"\' \'"+pmp42+"\'")
+        evfr.append(wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'")
         exes=evfr
         for e in exes:
             recdblist.printutf8(e)
@@ -64,10 +62,6 @@ def avi2mp4(pin,pout,opt):
                 txt=txt+unicode(commands.getoutput(e.encode('utf-8')),'utf-8')
             except:
                 ""
-        try:
-            shutil.move(pmp42,pout)
-        except:
-            ""
         if (not os.path.exists(pin.replace(".avi",".120.avi"))and (not os.path.exists(pout))):
             txt=txt+"CFR2TC error. maybe avi file is over 1GB.(ODML error would have happend.)"
             ptmp=pin.replace(".avi",".noodml.avi")
@@ -77,12 +71,10 @@ def avi2mp4(pin,pout,opt):
             ex2="nice -n 17 "+e2
             e3=exe+u" -aviraw video \'"+pin120+u"\'"
             ex3="nice -n 17 "+e3
-            e4=exe+u" -fps 29.97 -add \'"+videotpath+"\' -new \'"+pmp4+"\'"
+            e4=exe+u" -fps 29.97 -add \'"+videotpath+"\' -add \'"+pinaac+"\' -new \'"+pmp4+"\'"
             ex4="nice -n 17 "+e4
-            e5=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pmp42+"\'"
+            e5=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+pintimecode+u"\' \'Z:\\"+pmp4+"\' -o \'Z:\\"+pout+"\'"
             ex5="nice -n 17 "+e5
-            e6=exe+u" -add \'"+pinaac+"\' \'"+pmp42+"\'"
-            ex6="nice -n 17 "+e6
             recdblist.printutf8(e)
             txt=txt+e+"\n"
             try:
@@ -106,17 +98,9 @@ def avi2mp4(pin,pout,opt):
             except:
                 ""
             try:
-                cmdt=unicode(commands.getoutput(ex6.encode('utf-8')),'utf-8')
-            except:
-                ""
-            try:
                 os.remove(ptmp)
             except:
                 ""
-            try:
-                shutil.move(pmp42,pout)
-            except:
-                ""
             txt=txt+cmdt+"\n"
     else:
         try:
@@ -178,12 +162,10 @@ def mkv2mp4(pin,pout):
     videopath=os.path.join(dir,etitle+u"_video.264")
     timecodepath=os.path.join(dir,etitle+u"_1_timecode.txt")
     tmpmp4=os.path.join(dir,etitle+u".tmp.mp4")
-    tmpmp42=os.path.join(dir,etitle+u".mp4")
     exe0=exeb+u" tracks \'"+pin+u"\' 1:\'"+videopath+u"\' 2:\'"+audiopath+u"\'"
     exe1=exeb+u" timecodes_v2 \'"+pin+"\' 1:\'"+timecodepath+"\'"
-    exe2=exe+u" -fps 29.970030 -add \'"+videopath+u"\' -new \'"+tmpmp4+u"\'"
-    exe3=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+timecodepath+u"\' \'Z:\\"+tmpmp4+u"\' -o \'Z:\\"+tmpmp42+u"\'"
-    exe4=exe+u" -add \'"+audiopath+u"\' \'"+tmpmp42+u"\'"
+    exe2=exe+u" -fps 29.970030 -add \'"+videopath+u"\' -add \'"+audiopath+u"\' -new \'"+tmpmp4+u"\'"
+    exe3=wineexe+u" "+dtsedit+u" -tc \'Z:\\"+timecodepath+u"\' \'Z:\\"+tmpmp4+u"\' -o \'Z:\\"+pout+u"\'"
     logo=pin.replace(".avi",".log")
     os.environ['LANG']="ja_JP.UTF-8"
     txt= exe0+"\n"+exe1+"\n"+exe2+"\n"+exe3+"\n"
@@ -203,11 +185,6 @@ def mkv2mp4(pin,pout):
         os.system(exe3.encode('utf-8'))
     except:
         ""
-    try:
-        txt = txt+unicode(commands.getoutput(exe4.encode('utf-8')),'utf-8')
-    except:
-        ""
-    shutil.move(tmpmp42,pout)
     txt = "\n####MKV2MP4-log####\n"+txt
     f=open(logo,'a')
     f.write(txt.encode('utf-8'))
@@ -221,6 +198,4 @@ def mkv2mp4(pin,pout):
         if os.path.exists(timecodepath):
             os.remove(timecodepath)
         if os.path.exists(tmpmp4):
-            os.remove(tmpmp4)
-        if os.path.exists(tmpmp42):
-            os.remove(tmpmp42)
\ No newline at end of file
+            os.remove(tmpmp4)
\ No newline at end of file