Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -464,6 +464,7 @@ def wrap_text_for_ass(text: str, max_width: int, font_family: str, font_size: in
|
|
| 464 |
|
| 465 |
return "\\N".join(lines)
|
| 466 |
|
|
|
|
| 467 |
def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work_dir: str, font_path: str) -> str:
|
| 468 |
"""Create ASS subtitle file for captions with enhanced colors"""
|
| 469 |
|
|
@@ -487,7 +488,7 @@ def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work
|
|
| 487 |
bg_color_rgb = COLOR_MAP.get(bg_color_name, "000000")
|
| 488 |
# Convert RGB to BGR for background
|
| 489 |
bg_color_bgr = bg_color_rgb[4:6] + bg_color_rgb[2:4] + bg_color_rgb[0:2]
|
| 490 |
-
#
|
| 491 |
bg_alpha = int((1 - bg_opacity) * 255)
|
| 492 |
print(f"π¨ BG color: {bg_color_name} -> RGB={bg_color_rgb} -> BGR={bg_color_bgr}, Opacity={bg_opacity}, Alpha={bg_alpha}")
|
| 493 |
|
|
@@ -549,8 +550,11 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|
| 549 |
|
| 550 |
print(f"π Created caption ASS file with {len(captions)} captions")
|
| 551 |
print(f"π Style line: BorderStyle=3, Outline={style.padding}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
|
|
|
|
|
|
|
|
|
|
| 552 |
return ass_file
|
| 553 |
-
|
| 554 |
# =============================================
|
| 555 |
# SRT PARSING FUNCTIONS
|
| 556 |
# =============================================
|
|
|
|
| 464 |
|
| 465 |
return "\\N".join(lines)
|
| 466 |
|
| 467 |
+
|
| 468 |
def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work_dir: str, font_path: str) -> str:
|
| 469 |
"""Create ASS subtitle file for captions with enhanced colors"""
|
| 470 |
|
|
|
|
| 488 |
bg_color_rgb = COLOR_MAP.get(bg_color_name, "000000")
|
| 489 |
# Convert RGB to BGR for background
|
| 490 |
bg_color_bgr = bg_color_rgb[4:6] + bg_color_rgb[2:4] + bg_color_rgb[0:2]
|
| 491 |
+
# Alpha: 0 = opaque, 255 = transparent
|
| 492 |
bg_alpha = int((1 - bg_opacity) * 255)
|
| 493 |
print(f"π¨ BG color: {bg_color_name} -> RGB={bg_color_rgb} -> BGR={bg_color_bgr}, Opacity={bg_opacity}, Alpha={bg_alpha}")
|
| 494 |
|
|
|
|
| 550 |
|
| 551 |
print(f"π Created caption ASS file with {len(captions)} captions")
|
| 552 |
print(f"π Style line: BorderStyle=3, Outline={style.padding}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
|
| 553 |
+
|
| 554 |
+
# For captions, we need to use the ASS method (can't use drawtext for multiple timed captions)
|
| 555 |
+
# But we've improved the ASS formatting for better background rendering
|
| 556 |
return ass_file
|
| 557 |
+
|
| 558 |
# =============================================
|
| 559 |
# SRT PARSING FUNCTIONS
|
| 560 |
# =============================================
|