瀏覽代碼

fixing websocket

ming 3 年之前
父節點
當前提交
a144165920
共有 1 個文件被更改,包括 9 次插入8 次删除
  1. 9 8
      main.py

+ 9 - 8
main.py

@@ -494,23 +494,23 @@ def generate_subtitle_image(name_hash,text_content):
 
 
 def anchor_video_v2(name,text_content, image_urls,avatar):
-    #ws = create_connection("ws://www.choozmo.com:8888/progress")
+    ws = create_connection("ws://www.choozmo.com:8888/progress")
     progress = 0
     name_hash = str(time.time()).replace('.','')
     
     print('sub image made')
     file_prepare_v2(name, name_hash, text_content,image_urls)
     progress = 10
-    #ws.send(str(progress))
+    ws.send(str(progress))
     sub_list=generate_subtitle_image(name_hash,text_content)
     progress = 20
-    #ws.send(str(progress))
+    ws.send(str(progress))
     
     progress_per_video = int(40/len(text_content))
     for fname in range(len(text_content)):
         call_achor_video_v2(name_hash+"/"+str(fname),avatar)
         progress += progress_per_video
-        #ws.send(str(progress))
+        ws.send(str(progress))
         print('step finish')
     print('called............................................')
 
@@ -596,7 +596,7 @@ def anchor_video_v2(name,text_content, image_urls,avatar):
         idx+=1
 
     progress+=10
-    #ws.send(str(progress))
+    ws.send(str(progress))
     
     LOGO_ED = openshot.FFmpegReader(dir_video+"LOGO_ED.avi")
     LOGO_ED.Open()
@@ -641,16 +641,17 @@ def anchor_video_v2(name,text_content, image_urls,avatar):
     w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 1280, 720,
         openshot.Fraction(1, 1), False, False, 3000000)
     w.Open()
-    progress = 100
-    #ws.send(str(progress))
+    
     #may change duration into t.info.duration
     for n in range(int(t.info.fps)*int(head_duration+main_timer+ED_duration)):
         f=t.GetFrame(n)
         w.WriteFrame(f)
-    
+    progress = 100
+    ws.send(str(progress))
     notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+name_hash+".mp4")
     t.Close()
     w.Close()
+    ws.close()
     
     print("Raw Video done")
     print("video at : www.choozmo.com:8168/"+name_hash+".mp4")