Sfoglia il codice sorgente

add rpyc class and update Dockerfile

ming 3 anni fa
parent
commit
c0b8d9aca6

BIN
OpenshotService/__pycache__/openshot_video_generator.cpython-39.pyc


+ 10 - 30
OpenshotService/openshot_video_generator.py

@@ -64,8 +64,6 @@ def video_photo_clip(vid=None,layer=None, position=None, end=None
     return clip
 
 
-
-
 def myunichchar(unicode_char):
         mb_string = unicode_char.encode('big5')
         try:
@@ -106,7 +104,7 @@ def get_url_type(url):
     
 def make_dir(name_hash):
     for direct in dir_list:
-        if !(os.path.isdir(direct)):
+        if not os.path.isdir(direct):
             os.mkdir(direct)
     try:
         os.mkdir(dir_photo+name_hash)
@@ -260,25 +258,15 @@ async def sendProgress(progress,client_id):
     ws.close()
 
 def anchor_video_v2(name_hash,name,text_content, image_urls,avatar,client_id):
-    
-    progress = 0
-    asyncio.run(sendProgress(progress,client_id))
-    
-    
+
     print('sub image made')
     file_prepare_v2(name, name_hash, text_content,image_urls)
-    progress = 20
-    asyncio.run(sendProgress(progress,client_id))
     sub_list=generate_subtitle_image(name_hash,text_content)
-    progress = 30
-    asyncio.run(sendProgress(progress,client_id))
     
     progress_per_video = int(40/len(text_content))
     for fname in range(len(text_content)):
         call_anchor(name_hash+"/"+str(fname),avatar)
-        progress += progress_per_video
         print('step finish')
-        asyncio.run(sendProgress(progress,client_id))
     print('called............................................')
 
     ck=cKey(0,254,0,270)
@@ -305,8 +293,6 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,avatar,client_id):
     LOGO_OP.Close()
     progress += 10
     
-
-    
     clip_duration=0
     photo_clip_list = [None]*len(text_content)
     img_list = [None]*len(text_content)
@@ -344,8 +330,6 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,avatar,client_id):
         img_list[idx].Close()
         anchor_list[idx].Close()
         audio_list[idx].Close()
-
-     
             
         sub_img_list[idx] = [None] * len(sub_list[idx])
         sub_clip_list[idx] = [None] * len(sub_list[idx])
@@ -361,9 +345,6 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,avatar,client_id):
             print(sub_list[idx][sub_idx]['path'])
         main_timer += clip_duration
         idx+=1
-
-    progress+=10
-    asyncio.run(sendProgress(progress,client_id))
     
     LOGO_ED = openshot.FFmpegReader(dir_video+"LOGO_ED.avi")
     LOGO_ED.Open()
@@ -415,20 +396,19 @@ def anchor_video_v2(name_hash,name,text_content, image_urls,avatar,client_id):
         f=t.GetFrame(n)
         w.WriteFrame(f)
         
-            
-    progress = 100
-    asyncio.run(sendProgress(progress,client_id))
     notify_group(name+"的影片已經產生完成囉! www.choozmo.com:8168/"+name_hash+".mp4")
     t.Close()
     w.Close()
-
-
-    progress = 100
-    asyncio.run(sendProgress(progress,client_id))
-    print("Raw Video done")
     print("video at : www.choozmo.com:8168/"+name_hash+".mp4")
 
     #line notifs
-    
 
+class video_service(rpyc.Service):
+    def call_video(name_hash,name,text_content, image_urls,avatar,client_id):
+        anchor_video_v2(name_hash,name,text_content, image_urls,avatar,client_id)
+        
 
+if __name__ == "__main__":
+    from rpyc.utils.server import ThreadedServer
+    t = ThreadedServer(video_service, port=18861)
+    t.start()

+ 1 - 0
etc/Dockerfile

@@ -5,6 +5,7 @@ RUN apt install -y software-properties-common
 RUN add-apt-repository -y ppa:openshot.developers/ppa
 RUN apt update
 RUN apt-get update
+RUN DEBIAN_FRONTEND=noninteractive apt-get install keyboard-configuration
 RUN apt-get install python3-pip -y
 RUN apt-get install vim -y
 RUN pip3 install fastapi