qqwjq1981 commited on
Commit
526a5f6
·
verified ·
1 Parent(s): cf52a9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -387,14 +387,15 @@ def create_subtitle_clip_pil(text, start_time, end_time, video_width, video_heig
387
  lines.append(line)
388
  line = word
389
  lines.append(line)
390
-
 
391
  line_heights = [draw.textbbox((0, 0), l, font=font)[3] - draw.textbbox((0, 0), l, font=font)[1] for l in lines]
392
- total_height = sum(line_heights) + (len(lines) - 1) * 5
393
 
394
  img = Image.new("RGBA", (subtitle_width, total_height), (0, 0, 0, 0))
395
  draw = ImageDraw.Draw(img)
396
 
397
- def draw_text_with_outline(draw, pos, text, font, fill="yellow", outline="black", outline_width=2):
398
  x, y = pos
399
  # Draw outline
400
  for dx in range(-outline_width, outline_width + 1):
@@ -413,7 +414,7 @@ def create_subtitle_clip_pil(text, start_time, end_time, video_width, video_heig
413
  y += line_heights[idx] + 5
414
 
415
  img_np = np.array(img)
416
- margin = int(video_height * 0.1)
417
  img_clip = ImageClip(img_np) # Create the ImageClip first
418
  image_height = img_clip.size[1]
419
  txt_clip = (
 
387
  lines.append(line)
388
  line = word
389
  lines.append(line)
390
+
391
+ outline_width=2
392
  line_heights = [draw.textbbox((0, 0), l, font=font)[3] - draw.textbbox((0, 0), l, font=font)[1] for l in lines]
393
+ total_height = sum(line_heights) + (len(lines) - 1) * 5 + 2 * outline_width
394
 
395
  img = Image.new("RGBA", (subtitle_width, total_height), (0, 0, 0, 0))
396
  draw = ImageDraw.Draw(img)
397
 
398
+ def draw_text_with_outline(draw, pos, text, font, fill="yellow", outline="black", outline_width = outline_width):
399
  x, y = pos
400
  # Draw outline
401
  for dx in range(-outline_width, outline_width + 1):
 
414
  y += line_heights[idx] + 5
415
 
416
  img_np = np.array(img)
417
+ margin = int(video_height * 0.05)
418
  img_clip = ImageClip(img_np) # Create the ImageClip first
419
  image_height = img_clip.size[1]
420
  txt_clip = (