zhangyong hai 1 ano
pai
achega
f4336fcce8
Modificáronse 1 ficheiros con 9 adicións e 17 borrados
  1. 9 17
      video_agc/agc_video_method.py

+ 9 - 17
video_agc/agc_video_method.py

@@ -235,11 +235,7 @@ class AgcVidoe():
         s_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/srt/"
         # oss 目录
         v_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/oss/"
-        # oss
-        o_path_url = config['PATHS']['VIDEO_PATH'] + mark + "/oss/new/"
 
-        if not os.path.exists(o_path_url):
-            os.makedirs(o_path_url)
         if not os.path.exists(video_path_url):
             os.makedirs(video_path_url)
         if not os.path.exists(s_path_url):
@@ -250,7 +246,7 @@ class AgcVidoe():
         s_path = s_path_url + mark + ".srt"
         # 最终生成视频地址
         v_path = v_path_url + mark + ".mp4"
-        v_oss_path = o_path_url + mark + ".mp4"
+        v_oss_path = v_path_url + mark + "oss.mp4"
         if os.path.isfile(v_oss_path):
             os.remove(v_oss_path)
         if os.path.isfile(v_path):
@@ -275,8 +271,15 @@ class AgcVidoe():
             return ""
         print(f"{mark}的{platform}:开始拼接视频喽~~~")
         Common.logger("video").info(f"{mark}的{platform}:开始拼接视频喽~~~")
+        if os.path.exists(s_path):
+            # subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=11,Fontname=Hiragino Sans GB,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
+            subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=12,Fontname=wqy-zenhei,Bold=1,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
+        else:
+            # subtitle_cmd = "drawtext=text='分享、转发给群友':fontsize=28:fontcolor=black:x=(w-text_w)/2:y=h-text_h-15"
+            subtitle_cmd =  "drawtext=text='分享、转发给群友':x=(w-text_w)/2:y=h-text_h-15:fontsize=28:fontcolor=black:fontfile=/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc"
+        # 背景色参数
+        background_cmd = "drawbox=y=ih-65:color=yellow@1.0:width=iw:height=0:t=fill"
         VIDEO_COUNTER = 0
-        # 初始化FFmpeg的-filter_complex参数
         FF_INPUT = ""
         FF_SCALE = ""
         FF_FILTER = ""
@@ -298,17 +301,6 @@ class AgcVidoe():
                            "-map", "[v]", "-map", "[a]", v_path])
         subprocess.run(ffmpeg_cmd)
 
-        # 字幕参数
-        if os.path.exists(s_path):
-            # subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=11,Fontname=Hiragino Sans GB,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
-            subtitle_cmd = f"subtitles={s_path}:force_style='Fontsize=12,Fontname=wqy-zenhei,Bold=1,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000'"
-        else:
-            # subtitle_cmd = "drawtext=text='分享、转发给群友':fontsize=28:fontcolor=black:x=(w-text_w)/2:y=h-text_h-15"
-            subtitle_cmd =  "drawtext=text='分享、转发给群友':x=(w-text_w)/2:y=h-text_h-15:fontsize=28:fontcolor=black:fontfile=/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc"
-
-
-        # 背景色参数
-        background_cmd = "drawbox=y=ih-65:color=yellow@1.0:width=iw:height=0:t=fill"
         # 多线程数
         num_threads = 4
         # 构建 FFmpeg 命令,生成视频