Update app.py
Browse files
app.py
CHANGED
@@ -342,7 +342,12 @@ def update_translations(file, edited_table, mode):
|
|
342 |
def create_subtitle_clip_pil(text, start_time, end_time, video_width, video_height, font_path):
|
343 |
try:
|
344 |
subtitle_width = int(video_width * 0.8)
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
346 |
font = ImageFont.truetype(font_path, subtitle_font_size)
|
347 |
|
348 |
dummy_img = Image.new("RGBA", (subtitle_width, 1), (0, 0, 0, 0))
|
|
|
342 |
def create_subtitle_clip_pil(text, start_time, end_time, video_width, video_height, font_path):
|
343 |
try:
|
344 |
subtitle_width = int(video_width * 0.8)
|
345 |
+
aspect_ratio = video_height / video_width
|
346 |
+
if aspect_ratio > 1.2: # Portrait video
|
347 |
+
subtitle_font_size = int(video_width // 18)
|
348 |
+
else: # Landscape video
|
349 |
+
subtitle_font_size = int(video_height // 20)
|
350 |
+
|
351 |
font = ImageFont.truetype(font_path, subtitle_font_size)
|
352 |
|
353 |
dummy_img = Image.new("RGBA", (subtitle_width, 1), (0, 0, 0, 0))
|