Spaces:
Running on Zero
Running on Zero
Vicente Alvarez commited on
Commit ·
acfd94b
1
Parent(s): 56ff4c4
Fix PNG transparency: add format=auto to overlay filter for proper alpha blending
Browse files
app.py
CHANGED
|
@@ -487,16 +487,16 @@ def burn_subtitles_and_watermark(video_path: str, output_path: str, subtitle_pat
|
|
| 487 |
|
| 488 |
# Build filter complex
|
| 489 |
if subtitle_path and watermark_path and os.path.exists(subtitle_path) and os.path.exists(watermark_path):
|
| 490 |
-
# Both subtitles and watermark: subtitles first, then overlay watermark at position 0,0
|
| 491 |
-
filter_complex = f"[0:v]subtitles={subtitle_path}:force_style='FontName=Montserrat SemiBold'[v];[v][1:v]overlay=0:0"
|
| 492 |
cmd.extend(['-filter_complex', filter_complex])
|
| 493 |
elif subtitle_path and os.path.exists(subtitle_path):
|
| 494 |
# Only subtitles
|
| 495 |
filter_complex = f"subtitles={subtitle_path}:force_style='FontName=Montserrat SemiBold'"
|
| 496 |
cmd.extend(['-vf', filter_complex])
|
| 497 |
elif watermark_path and os.path.exists(watermark_path):
|
| 498 |
-
# Only watermark: overlay at 0,0
|
| 499 |
-
filter_complex = "[0:v][1:v]overlay=0:0"
|
| 500 |
cmd.extend(['-filter_complex', filter_complex])
|
| 501 |
|
| 502 |
cmd.extend(['-c:a', 'copy', output_path])
|
|
|
|
| 487 |
|
| 488 |
# Build filter complex
|
| 489 |
if subtitle_path and watermark_path and os.path.exists(subtitle_path) and os.path.exists(watermark_path):
|
| 490 |
+
# Both subtitles and watermark: subtitles first, then overlay watermark with alpha at position 0,0
|
| 491 |
+
filter_complex = f"[0:v]subtitles={subtitle_path}:force_style='FontName=Montserrat SemiBold'[v];[v][1:v]overlay=0:0:format=auto"
|
| 492 |
cmd.extend(['-filter_complex', filter_complex])
|
| 493 |
elif subtitle_path and os.path.exists(subtitle_path):
|
| 494 |
# Only subtitles
|
| 495 |
filter_complex = f"subtitles={subtitle_path}:force_style='FontName=Montserrat SemiBold'"
|
| 496 |
cmd.extend(['-vf', filter_complex])
|
| 497 |
elif watermark_path and os.path.exists(watermark_path):
|
| 498 |
+
# Only watermark: overlay at 0,0 with alpha transparency support
|
| 499 |
+
filter_complex = "[0:v][1:v]overlay=0:0:format=auto"
|
| 500 |
cmd.extend(['-filter_complex', filter_complex])
|
| 501 |
|
| 502 |
cmd.extend(['-c:a', 'copy', output_path])
|