Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,17 +73,23 @@ def create_sentence_base_filter(full_text, duration_clip, font_option, font_size
|
|
| 73 |
escaped_text = full_text.replace(':', FFMPEG_ESCAPE_CHAR + ':')
|
| 74 |
|
| 75 |
# Filter für den gesamten Satz, sichtbar für die gesamte Clip-Dauer
|
| 76 |
-
|
| 77 |
f"drawtext=text='{escaped_text}':"
|
| 78 |
f"fontcolor={base_params['fontcolor']}:"
|
| 79 |
f"fontsize={base_params['fontsize']}:"
|
| 80 |
f"borderw={base_params['borderw']}:"
|
| 81 |
f"bordercolor={base_params['bordercolor']}:"
|
| 82 |
+ (f"box={base_params['box']}:boxcolor={base_params['boxcolor']}:boxborderw=10:" if base_params["box"] else "") +
|
| 83 |
-
f"x=(w-text_w)/2:y=(h-text_h)*{y_pos}
|
| 84 |
-
f"enable='between(t, 0, {duration_clip})'"
|
| 85 |
)
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
def create_highlight_word_filter(word, full_text, start_time, duration, font_option, font_size, y_pos, style):
|
| 89 |
"""
|
|
@@ -149,17 +155,23 @@ def create_highlight_word_filter(word, full_text, start_time, duration, font_opt
|
|
| 149 |
escaped_word = word.replace(':', FFMPEG_ESCAPE_CHAR + ':')
|
| 150 |
|
| 151 |
# Filter für das einzelne, hervorgehobene Wort
|
| 152 |
-
|
| 153 |
f"drawtext=text='{escaped_word}':"
|
| 154 |
f"fontcolor={params['fontcolor']}:"
|
| 155 |
f"fontsize={params['fontsize_override']}:"
|
| 156 |
f"borderw={params['borderw']}:"
|
| 157 |
f"bordercolor={params['bordercolor']}:"
|
| 158 |
+ (f"box={params['box']}:boxcolor={params['boxcolor']}:boxborderw=10:" if params["box"] else "") +
|
| 159 |
-
f"x=(w-text_w)/2:y=(h-text_h)*{y_pos}
|
| 160 |
-
f"alpha='{alpha_expression}'"
|
| 161 |
)
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
def generate_slideshow_with_audio(images, input_text, duration_per_word, duration_per_image, fade_duration, font_size, y_pos, audio_file, subtitle_style):
|
| 165 |
|
|
@@ -182,7 +194,8 @@ def generate_slideshow_with_audio(images, input_text, duration_per_word, duratio
|
|
| 182 |
|
| 183 |
# Schriftart finden
|
| 184 |
font_path = get_font_path()
|
| 185 |
-
font_option
|
|
|
|
| 186 |
|
| 187 |
# Audio verarbeiten
|
| 188 |
audio_temp_dir, temp_audio_file = save_temp_audio(audio_file) if audio_file else (None, None)
|
|
@@ -247,6 +260,7 @@ def generate_slideshow_with_audio(images, input_text, duration_per_word, duratio
|
|
| 247 |
]
|
| 248 |
|
| 249 |
try:
|
|
|
|
| 250 |
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
| 251 |
clips_with_text.append(clip_path)
|
| 252 |
except subprocess.CalledProcessError as e:
|
|
@@ -348,4 +362,4 @@ with gr.Blocks() as demo:
|
|
| 348 |
outputs=[out_video, status]
|
| 349 |
)
|
| 350 |
|
| 351 |
-
demo.launch(
|
|
|
|
| 73 |
escaped_text = full_text.replace(':', FFMPEG_ESCAPE_CHAR + ':')
|
| 74 |
|
| 75 |
# Filter für den gesamten Satz, sichtbar für die gesamte Clip-Dauer
|
| 76 |
+
drawtext_filter = (
|
| 77 |
f"drawtext=text='{escaped_text}':"
|
| 78 |
f"fontcolor={base_params['fontcolor']}:"
|
| 79 |
f"fontsize={base_params['fontsize']}:"
|
| 80 |
f"borderw={base_params['borderw']}:"
|
| 81 |
f"bordercolor={base_params['bordercolor']}:"
|
| 82 |
+ (f"box={base_params['box']}:boxcolor={base_params['boxcolor']}:boxborderw=10:" if base_params["box"] else "") +
|
| 83 |
+
f"x=(w-text_w)/2:y=(h-text_h)*{y_pos}"
|
|
|
|
| 84 |
)
|
| 85 |
|
| 86 |
+
# Korrigierte Logik, um doppelte Doppelpunkte zu vermeiden
|
| 87 |
+
if font_option:
|
| 88 |
+
drawtext_filter += f":{font_option}"
|
| 89 |
+
|
| 90 |
+
drawtext_filter += f":enable='between(t, 0, {duration_clip})'"
|
| 91 |
+
return drawtext_filter
|
| 92 |
+
|
| 93 |
|
| 94 |
def create_highlight_word_filter(word, full_text, start_time, duration, font_option, font_size, y_pos, style):
|
| 95 |
"""
|
|
|
|
| 155 |
escaped_word = word.replace(':', FFMPEG_ESCAPE_CHAR + ':')
|
| 156 |
|
| 157 |
# Filter für das einzelne, hervorgehobene Wort
|
| 158 |
+
drawtext_filter = (
|
| 159 |
f"drawtext=text='{escaped_word}':"
|
| 160 |
f"fontcolor={params['fontcolor']}:"
|
| 161 |
f"fontsize={params['fontsize_override']}:"
|
| 162 |
f"borderw={params['borderw']}:"
|
| 163 |
f"bordercolor={params['bordercolor']}:"
|
| 164 |
+ (f"box={params['box']}:boxcolor={params['boxcolor']}:boxborderw=10:" if params["box"] else "") +
|
| 165 |
+
f"x=(w-text_w)/2:y=(h-text_h)*{y_pos}"
|
|
|
|
| 166 |
)
|
| 167 |
|
| 168 |
+
# Korrigierte Logik, um doppelte Doppelpunkte zu vermeiden
|
| 169 |
+
if font_option:
|
| 170 |
+
drawtext_filter += f":{font_option}"
|
| 171 |
+
|
| 172 |
+
drawtext_filter += f":alpha='{alpha_expression}'"
|
| 173 |
+
return drawtext_filter
|
| 174 |
+
|
| 175 |
|
| 176 |
def generate_slideshow_with_audio(images, input_text, duration_per_word, duration_per_image, fade_duration, font_size, y_pos, audio_file, subtitle_style):
|
| 177 |
|
|
|
|
| 194 |
|
| 195 |
# Schriftart finden
|
| 196 |
font_path = get_font_path()
|
| 197 |
+
# font_option enthält jetzt NUR den Parameter-Teil, OHNE führenden Doppelpunkt.
|
| 198 |
+
font_option = f"fontfile='{font_path}'" if font_path else ""
|
| 199 |
|
| 200 |
# Audio verarbeiten
|
| 201 |
audio_temp_dir, temp_audio_file = save_temp_audio(audio_file) if audio_file else (None, None)
|
|
|
|
| 260 |
]
|
| 261 |
|
| 262 |
try:
|
| 263 |
+
# Hinzufügen von stdout/stderr Erfassung für bessere Fehlerprotokollierung
|
| 264 |
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
| 265 |
clips_with_text.append(clip_path)
|
| 266 |
except subprocess.CalledProcessError as e:
|
|
|
|
| 362 |
outputs=[out_video, status]
|
| 363 |
)
|
| 364 |
|
| 365 |
+
demo.launch(
|