yukee1992 commited on
Commit
7a161cf
Β·
verified Β·
1 Parent(s): d262331

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -468,6 +468,7 @@ def wrap_text_for_ass(text: str, max_width: int, font_family: str, font_size: in
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
 
@@ -510,6 +511,7 @@ def create_caption_ass(captions: List[CaptionSegment], style: CaptionStyle, work
510
 
511
  # Create ASS header with proper border settings
512
  # BorderStyle=3 gives solid box, Outline adds text border
 
513
  ass_header = f"""[Script Info]
514
  ; Script generated by Video Styling Space - Auto Caption
515
  ScriptType: v4.00+
@@ -520,7 +522,7 @@ WrapStyle: 1
520
 
521
  [V4+ Styles]
522
  Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
523
- Style: Default,{font_family_name},{style.font_size},&H00{font_color_bgr},&H000000FF,&H{outline_color_bgr},&H{bg_alpha:02X}{bg_color_bgr},0,0,0,0,100,100,0,0,3,{style.outline_width},0,{alignment},{margin_l},{margin_r},{margin_v},1
524
 
525
  [Events]
526
  Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
@@ -549,9 +551,8 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
549
  print("=== END ASS DEBUG ===\n")
550
 
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
@@ -686,6 +687,7 @@ def create_text_overlay(input_video, output_video, text_style):
686
 
687
  # Create ASS file content with solid rectangle background and outline
688
  # BorderStyle=3 gives solid box, Outline adds text border
 
689
  ass_content = f"""[Script Info]
690
  ; Script generated by Video Styling Space
691
  ScriptType: v4.00+
@@ -695,7 +697,7 @@ ScaledBorderAndShadow: yes
695
 
696
  [V4+ Styles]
697
  Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
698
- Style: Default,{font_family_name},{text_style.font_size},&H00{font_color_bgr},&H000000FF,&H{outline_color_bgr},&H{bg_alpha:02X}{bg_color_bgr},0,0,0,0,100,100,0,0,3,{text_style.outline_width},0,{alignment},{margin_l},{margin_r},{margin_v},1
699
 
700
  [Events]
701
  Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
@@ -712,7 +714,7 @@ Dialogue: 0,0:00:00.00,0:00:10.00,Default,,0,0,0,,{text_style.text}"""
712
  print("=== END ASS DEBUG ===\n")
713
 
714
  print(f"πŸ“ Created ASS subtitle file with font family: {font_family_name}")
715
- print(f"πŸ“ Style line: BorderStyle=3, Outline={text_style.outline_width}, OutlineColor=&H{outline_color_bgr}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
716
 
717
  # Run FFmpeg with ASS filter
718
  cmd = [
@@ -1490,7 +1492,7 @@ async def add_captions_from_srt(request: SrtCaptionRequest):
1490
  async def root():
1491
  return {
1492
  "name": "Text Styling API with Auto Caption",
1493
- "version": "3.5.0",
1494
  "features": {
1495
  "title_overlay": "βœ…",
1496
  "manual_captions": "βœ…",
 
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
 
 
511
 
512
  # Create ASS header with proper border settings
513
  # BorderStyle=3 gives solid box, Outline adds text border
514
+ # Format: &HAABBGGRR where AA is alpha, BB blue, GG green, RR red
515
  ass_header = f"""[Script Info]
516
  ; Script generated by Video Styling Space - Auto Caption
517
  ScriptType: v4.00+
 
522
 
523
  [V4+ Styles]
524
  Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
525
+ Style: Default,{font_family_name},{style.font_size},&H00{font_color_bgr},&H000000FF,&H00{outline_color_bgr},&H{bg_alpha:02X}{bg_color_bgr},0,0,0,0,100,100,0,0,3,{style.outline_width},0,{alignment},{margin_l},{margin_r},{margin_v},1
526
 
527
  [Events]
528
  Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
 
551
  print("=== END ASS DEBUG ===\n")
552
 
553
  print(f"πŸ“ Created caption ASS file with {len(captions)} captions")
554
+ print(f"πŸ“ Style line: BorderStyle=3, Outline={style.outline_width}, OutlineColor=&H00{outline_color_bgr}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
555
  return ass_file
 
556
 
557
  # =============================================
558
  # SRT PARSING FUNCTIONS
 
687
 
688
  # Create ASS file content with solid rectangle background and outline
689
  # BorderStyle=3 gives solid box, Outline adds text border
690
+ # Format: &HAABBGGRR where AA is alpha, BB blue, GG green, RR red
691
  ass_content = f"""[Script Info]
692
  ; Script generated by Video Styling Space
693
  ScriptType: v4.00+
 
697
 
698
  [V4+ Styles]
699
  Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
700
+ Style: Default,{font_family_name},{text_style.font_size},&H00{font_color_bgr},&H000000FF,&H00{outline_color_bgr},&H{bg_alpha:02X}{bg_color_bgr},0,0,0,0,100,100,0,0,3,{text_style.outline_width},0,{alignment},{margin_l},{margin_r},{margin_v},1
701
 
702
  [Events]
703
  Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
 
714
  print("=== END ASS DEBUG ===\n")
715
 
716
  print(f"πŸ“ Created ASS subtitle file with font family: {font_family_name}")
717
+ print(f"πŸ“ Style line: BorderStyle=3, Outline={text_style.outline_width}, OutlineColor=&H00{outline_color_bgr}, BackColor=&H{bg_alpha:02X}{bg_color_bgr}")
718
 
719
  # Run FFmpeg with ASS filter
720
  cmd = [
 
1492
  async def root():
1493
  return {
1494
  "name": "Text Styling API with Auto Caption",
1495
+ "version": "3.6.0",
1496
  "features": {
1497
  "title_overlay": "βœ…",
1498
  "manual_captions": "βœ…",