Browse Source

分享引导字幕背景色 优化

zhangyong 11 months ago
parent
commit
37a8a9df22
2 changed files with 6 additions and 3 deletions
  1. 5 2
      common/ffmpeg.py
  2. 1 1
      video_job.py

+ 5 - 2
common/ffmpeg.py

@@ -194,8 +194,11 @@ class FFmpeg():
         pw_duration = cls.get_video_duration(pw_url)
         time.sleep(2)
         # 添加字幕 wqy-zenhei  Hiragino Sans GB
-        subtitle_cmd = f"subtitles={pw_srt_path}:force_style='Fontsize=16,Fontname=wqy-zenhei,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000,Bold=1,MarginV=135'"
-        background_cmd = f"drawbox=y=(ih-{int(height)}/2-{int(height)}/2):color=yellow@1.0:width=iw:height={int(height)}/4:t=fill"
+        margin_v = int(height) // 8  # 可根据需要调整字幕和背景之间的距离
+        subtitle_cmd = f"subtitles={pw_srt_path}:force_style='Fontsize=14,Fontname=wqy-zenhei,Outline=0,PrimaryColour=&H000000,SecondaryColour=&H000000,Bold=1,MarginV={margin_v}'"
+        bg_position_offset = (int(height) - margin_v) / 1.75
+        background_cmd = f"drawbox=y=(ih-{int(height)}/2-{bg_position_offset}):color=yellow@1.0:width=iw:height={int(height)}/4:t=fill"
+
         ffmpeg_cmd = [
             'ffmpeg',
             '-loop', '1',

+ 1 - 1
video_job.py

@@ -71,7 +71,7 @@ def usernames_today():
     print("today 已清空")
 
 
-video_start()
+# video_start()
 
 
 # 定时任务设置