Fix TextClip font parameter syntax and duration handling

- Use text= keyword parameter instead of positional
- Change fontsize= to font_size= (correct MoviePy parameter)
- Remove font= parameter that was causing conflicts
- Set duration in TextClip constructor instead of separate method
- Text overlays should now work properly in MCP tools
This commit is contained in:
Ryan Malloy 2025-09-05 05:29:05 -06:00
parent 3e858dc20e
commit 3a4c3e8f77

View File

@ -359,27 +359,20 @@ def mcp_video_add_overlay(
with VideoFileClip(input_path) as clip:
if overlay_type == "text" and text:
# Default style
default_style = {"fontsize": 50, "color": "white", "font": "Arial-Bold"}
# Default style (corrected parameter names)
default_style = {"font_size": 50, "color": "white"}
if style:
default_style.update(style)
# Create text clip
txt_clip = (
TextClip(
text,
fontsize=default_style["fontsize"],
color=default_style["color"],
font=default_style["font"],
)
.set_position(position)
.set_start(start_time)
)
# Create text clip with correct syntax
txt_clip = TextClip(
text=text,
font_size=default_style["font_size"],
color=default_style["color"],
duration=duration or (clip.duration - start_time)
).with_position(position).with_start(start_time)
if duration:
txt_clip = txt_clip.set_duration(duration)
else:
txt_clip = txt_clip.set_duration(clip.duration - start_time)
# Duration is already set in TextClip constructor
# Composite video with text overlay
final_clip = CompositeVideoClip([clip, txt_clip])