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:
parent
3e858dc20e
commit
3a4c3e8f77
@ -359,27 +359,20 @@ def mcp_video_add_overlay(
|
|||||||
|
|
||||||
with VideoFileClip(input_path) as clip:
|
with VideoFileClip(input_path) as clip:
|
||||||
if overlay_type == "text" and text:
|
if overlay_type == "text" and text:
|
||||||
# Default style
|
# Default style (corrected parameter names)
|
||||||
default_style = {"fontsize": 50, "color": "white", "font": "Arial-Bold"}
|
default_style = {"font_size": 50, "color": "white"}
|
||||||
if style:
|
if style:
|
||||||
default_style.update(style)
|
default_style.update(style)
|
||||||
|
|
||||||
# Create text clip
|
# Create text clip with correct syntax
|
||||||
txt_clip = (
|
txt_clip = TextClip(
|
||||||
TextClip(
|
text=text,
|
||||||
text,
|
font_size=default_style["font_size"],
|
||||||
fontsize=default_style["fontsize"],
|
|
||||||
color=default_style["color"],
|
color=default_style["color"],
|
||||||
font=default_style["font"],
|
duration=duration or (clip.duration - start_time)
|
||||||
)
|
).with_position(position).with_start(start_time)
|
||||||
.set_position(position)
|
|
||||||
.set_start(start_time)
|
|
||||||
)
|
|
||||||
|
|
||||||
if duration:
|
# Duration is already set in TextClip constructor
|
||||||
txt_clip = txt_clip.set_duration(duration)
|
|
||||||
else:
|
|
||||||
txt_clip = txt_clip.set_duration(clip.duration - start_time)
|
|
||||||
|
|
||||||
# Composite video with text overlay
|
# Composite video with text overlay
|
||||||
final_clip = CompositeVideoClip([clip, txt_clip])
|
final_clip = CompositeVideoClip([clip, txt_clip])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user