浏览代码

change os rename to copy and remove

ming 3 年之前
父节点
当前提交
db13d39239
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      api/main.py

+ 3 - 1
api/main.py

@@ -26,6 +26,7 @@ import dataset
 from datetime import datetime
 from util.swap_face import swap_face
 from fastapi.staticfiles import StaticFiles
+import shutil
 #test
 
 app = FastAPI()
@@ -135,5 +136,6 @@ def gen_video(name_hash,name,text_content, image_urls,avatar,client_id):
     remote_svc = c.root
     my_answer = remote_svc.call_video(name_hash,name,text_content, image_urls,avatar,client_id) # method call
     
-    os.rename(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
+    shutil.copy(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
+    os.remove(tmp_video_dir+name_hash+'.mp4')