Vicente Alvarez Claude Sonnet 4.5 commited on
Commit
d1b769c
·
1 Parent(s): 92516fd

Add debug logging for subtitle path and FFmpeg command

Browse files

Escape subtitle path and add detailed logging to debug subtitle visibility issue.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -513,20 +513,25 @@ def burn_subtitles_and_watermark(video_path: str, output_path: str, subtitle_pat
513
 
514
  # Step 2: Apply subtitles if needed (second pass)
515
  if subtitle_path and os.path.exists(subtitle_path):
516
- print(f"[burn] Pass 2: Burning subtitles...")
 
 
 
517
 
518
  cmd = [
519
  'ffmpeg', '-y', '-i', current_video,
520
- '-vf', f"subtitles={subtitle_path}:force_style='FontName=Montserrat SemiBold'",
521
  '-c:a', 'copy', '-pix_fmt', 'yuv420p',
522
  output_path
523
  ]
524
 
 
525
  result = subprocess.run(cmd, capture_output=True, text=True)
526
  if result.returncode != 0:
527
- raise Exception(f"Subtitle pass failed: {result.stderr[-200:]}")
 
528
 
529
- print(f"[burn] Subtitles burned")
530
  elif current_video != video_path:
531
  # Only watermark was applied, move temp file to output
532
  import shutil
@@ -732,6 +737,10 @@ def full_generation_process(
732
  if add_subtitles and subtitle_segments:
733
  subtitle_file = tempfile.mktemp(suffix=".ass")
734
  create_beautiful_ass_subtitles(subtitle_segments, subtitle_file, int(width), int(height))
 
 
 
 
735
 
736
  # Burn subtitles and/or watermark
737
  output_with_extras = tempfile.mktemp(suffix=".mp4")
 
513
 
514
  # Step 2: Apply subtitles if needed (second pass)
515
  if subtitle_path and os.path.exists(subtitle_path):
516
+ print(f"[burn] Pass 2: Burning subtitles from {subtitle_path}...")
517
+
518
+ # Escape the subtitle path for FFmpeg (replace : with \\: and \ with /)
519
+ subtitle_path_escaped = subtitle_path.replace('\\', '/').replace(':', '\\:')
520
 
521
  cmd = [
522
  'ffmpeg', '-y', '-i', current_video,
523
+ '-vf', f"subtitles='{subtitle_path_escaped}':force_style='FontName=Montserrat SemiBold'",
524
  '-c:a', 'copy', '-pix_fmt', 'yuv420p',
525
  output_path
526
  ]
527
 
528
+ print(f"[burn] FFmpeg command: {' '.join(cmd)}")
529
  result = subprocess.run(cmd, capture_output=True, text=True)
530
  if result.returncode != 0:
531
+ print(f"[burn] Subtitle stderr: {result.stderr}")
532
+ raise Exception(f"Subtitle pass failed: {result.stderr[-500:]}")
533
 
534
+ print(f"[burn] Subtitles burned successfully")
535
  elif current_video != video_path:
536
  # Only watermark was applied, move temp file to output
537
  import shutil
 
737
  if add_subtitles and subtitle_segments:
738
  subtitle_file = tempfile.mktemp(suffix=".ass")
739
  create_beautiful_ass_subtitles(subtitle_segments, subtitle_file, int(width), int(height))
740
+ print(f"[subtitles] Created subtitle file: {subtitle_file}, exists: {os.path.exists(subtitle_file)}")
741
+ if os.path.exists(subtitle_file):
742
+ with open(subtitle_file, 'r') as f:
743
+ print(f"[subtitles] File size: {len(f.read())} bytes")
744
 
745
  # Burn subtitles and/or watermark
746
  output_with_extras = tempfile.mktemp(suffix=".mp4")