Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -468,7 +468,6 @@ def wrap_text_for_ass(text: str, max_width: int, font_family: str, font_size: in
|
|
| 468 |
|
| 469 |
return "\\N".join(lines)
|
| 470 |
|
| 471 |
-
|
| 472 |
def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work_dir: str, font_path: str) -> str:
|
| 473 |
"""Create ASS subtitle file for captions with enhanced colors and outlines"""
|
| 474 |
|
|
@@ -479,12 +478,12 @@ def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work
|
|
| 479 |
# Get font color and convert from RRGGBB to BBGGRR for ASS
|
| 480 |
font_color_rgb = COLOR_MAP.get(style.color.lower(), "FFFFFF")
|
| 481 |
font_color_bgr = font_color_rgb[4:6] + font_color_rgb[2:4] + font_color_rgb[0:2]
|
| 482 |
-
print(f"π¨ Font color: {style.color} -> RGB={font_color_rgb} -> BGR={font_color_bgr}")
|
| 483 |
|
| 484 |
# Get outline color and convert to BGR
|
| 485 |
outline_color_rgb = COLOR_MAP.get(style.outline_color.lower(), "000000")
|
| 486 |
outline_color_bgr = outline_color_rgb[4:6] + outline_color_rgb[2:4] + outline_color_rgb[0:2]
|
| 487 |
-
print(f"βοΈ Outline color: {style.outline_color} -> RGB={outline_color_rgb} -> BGR={outline_color_bgr}, Width={style.outline_width}")
|
| 488 |
|
| 489 |
# Parse background color with proper alpha calculation
|
| 490 |
bg_parts = style.bg_color.split('@')
|
|
@@ -494,7 +493,7 @@ def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work
|
|
| 494 |
bg_color_rgb = COLOR_MAP.get(bg_color_name, "000000")
|
| 495 |
bg_color_bgr = bg_color_rgb[4:6] + bg_color_rgb[2:4] + bg_color_rgb[0:2]
|
| 496 |
bg_alpha = int((1 - bg_opacity) * 255)
|
| 497 |
-
print(f"π¨ BG color: {bg_color_name} -> RGB={bg_color_rgb} -> BGR={bg_color_bgr}, Opacity={bg_opacity}, Alpha={bg_alpha}")
|
| 498 |
|
| 499 |
# Map position to ASS alignment
|
| 500 |
pos_map = {
|
|
@@ -552,6 +551,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|
| 552 |
print(f"π Created caption ASS file with {len(captions)} captions")
|
| 553 |
print(f"π Style line: BorderStyle=3, Outline={style.outline_width}, OutlineColor=&H{outline_color_bgr}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
|
| 554 |
return ass_file
|
|
|
|
| 555 |
|
| 556 |
# =============================================
|
| 557 |
# SRT PARSING FUNCTIONS
|
|
@@ -641,12 +641,12 @@ def create_text_overlay(input_video, output_video, text_style):
|
|
| 641 |
# Get font color and convert from RRGGBB to BBGGRR for ASS
|
| 642 |
font_color_rgb = LOCAL_COLOR_MAP.get(text_style.color.lower(), "FFFFFF")
|
| 643 |
font_color_bgr = font_color_rgb[4:6] + font_color_rgb[2:4] + font_color_rgb[0:2]
|
| 644 |
-
print(f"π¨ Font color: {text_style.color} -> RGB={font_color_rgb} -> BGR={font_color_bgr}")
|
| 645 |
|
| 646 |
# Get outline color and convert to BGR
|
| 647 |
outline_color_rgb = LOCAL_COLOR_MAP.get(text_style.outline_color.lower(), "000000")
|
| 648 |
outline_color_bgr = outline_color_rgb[4:6] + outline_color_rgb[2:4] + outline_color_rgb[0:2]
|
| 649 |
-
print(f"βοΈ Outline color: {text_style.outline_color} -> RGB={outline_color_rgb} -> BGR={outline_color_bgr}, Width={text_style.outline_width}")
|
| 650 |
|
| 651 |
# Parse background color
|
| 652 |
bg_parts = text_style.bg_color.split('@')
|
|
@@ -656,7 +656,7 @@ def create_text_overlay(input_video, output_video, text_style):
|
|
| 656 |
bg_color_rgb = LOCAL_COLOR_MAP.get(bg_color_name, "000000")
|
| 657 |
bg_color_bgr = bg_color_rgb[4:6] + bg_color_rgb[2:4] + bg_color_rgb[0:2]
|
| 658 |
bg_alpha = int((1 - bg_opacity) * 255)
|
| 659 |
-
print(f"π¨ BG color: {bg_color_name} -> RGB={bg_color_rgb} -> BGR={bg_color_bgr}, Opacity={bg_opacity}, Alpha={bg_alpha}")
|
| 660 |
|
| 661 |
# Map position to ASS alignment
|
| 662 |
pos_map = {
|
|
|
|
| 468 |
|
| 469 |
return "\\N".join(lines)
|
| 470 |
|
|
|
|
| 471 |
def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work_dir: str, font_path: str) -> str:
|
| 472 |
"""Create ASS subtitle file for captions with enhanced colors and outlines"""
|
| 473 |
|
|
|
|
| 478 |
# Get font color and convert from RRGGBB to BBGGRR for ASS
|
| 479 |
font_color_rgb = COLOR_MAP.get(style.color.lower(), "FFFFFF")
|
| 480 |
font_color_bgr = font_color_rgb[4:6] + font_color_rgb[2:4] + font_color_rgb[0:2]
|
| 481 |
+
print(f"π¨ Font color (text): {style.color} -> RGB={font_color_rgb} -> BGR={font_color_bgr}")
|
| 482 |
|
| 483 |
# Get outline color and convert to BGR
|
| 484 |
outline_color_rgb = COLOR_MAP.get(style.outline_color.lower(), "000000")
|
| 485 |
outline_color_bgr = outline_color_rgb[4:6] + outline_color_rgb[2:4] + outline_color_rgb[0:2]
|
| 486 |
+
print(f"βοΈ Outline color (border): {style.outline_color} -> RGB={outline_color_rgb} -> BGR={outline_color_bgr}, Width={style.outline_width}")
|
| 487 |
|
| 488 |
# Parse background color with proper alpha calculation
|
| 489 |
bg_parts = style.bg_color.split('@')
|
|
|
|
| 493 |
bg_color_rgb = COLOR_MAP.get(bg_color_name, "000000")
|
| 494 |
bg_color_bgr = bg_color_rgb[4:6] + bg_color_rgb[2:4] + bg_color_rgb[0:2]
|
| 495 |
bg_alpha = int((1 - bg_opacity) * 255)
|
| 496 |
+
print(f"π¨ BG color (rectangle): {bg_color_name} -> RGB={bg_color_rgb} -> BGR={bg_color_bgr}, Opacity={bg_opacity}, Alpha={bg_alpha}")
|
| 497 |
|
| 498 |
# Map position to ASS alignment
|
| 499 |
pos_map = {
|
|
|
|
| 551 |
print(f"π Created caption ASS file with {len(captions)} captions")
|
| 552 |
print(f"π Style line: BorderStyle=3, Outline={style.outline_width}, OutlineColor=&H{outline_color_bgr}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
|
| 553 |
return ass_file
|
| 554 |
+
|
| 555 |
|
| 556 |
# =============================================
|
| 557 |
# SRT PARSING FUNCTIONS
|
|
|
|
| 641 |
# Get font color and convert from RRGGBB to BBGGRR for ASS
|
| 642 |
font_color_rgb = LOCAL_COLOR_MAP.get(text_style.color.lower(), "FFFFFF")
|
| 643 |
font_color_bgr = font_color_rgb[4:6] + font_color_rgb[2:4] + font_color_rgb[0:2]
|
| 644 |
+
print(f"π¨ Font color (text): {text_style.color} -> RGB={font_color_rgb} -> BGR={font_color_bgr}")
|
| 645 |
|
| 646 |
# Get outline color and convert to BGR
|
| 647 |
outline_color_rgb = LOCAL_COLOR_MAP.get(text_style.outline_color.lower(), "000000")
|
| 648 |
outline_color_bgr = outline_color_rgb[4:6] + outline_color_rgb[2:4] + outline_color_rgb[0:2]
|
| 649 |
+
print(f"βοΈ Outline color (border): {text_style.outline_color} -> RGB={outline_color_rgb} -> BGR={outline_color_bgr}, Width={text_style.outline_width}")
|
| 650 |
|
| 651 |
# Parse background color
|
| 652 |
bg_parts = text_style.bg_color.split('@')
|
|
|
|
| 656 |
bg_color_rgb = LOCAL_COLOR_MAP.get(bg_color_name, "000000")
|
| 657 |
bg_color_bgr = bg_color_rgb[4:6] + bg_color_rgb[2:4] + bg_color_rgb[0:2]
|
| 658 |
bg_alpha = int((1 - bg_opacity) * 255)
|
| 659 |
+
print(f"π¨ BG color (rectangle): {bg_color_name} -> RGB={bg_color_rgb} -> BGR={bg_color_bgr}, Opacity={bg_opacity}, Alpha={bg_alpha}")
|
| 660 |
|
| 661 |
# Map position to ASS alignment
|
| 662 |
pos_map = {
|