Moviepy-Python-Bilder und -Text mit farbigem Hintergrundvideo
Posted: 07 Jan 2025, 13:06
Ich versuche, mit Moviepy Python ein Video wie unten zu erstellen.?
Video -
https://assets.json2video.com/examples/ ... lide-text- right.mp4
Ist das mit Moviepy Python möglich? Ich kann FFMPEG nicht verwenden, da es auf meinem Server nicht unterstützt wird.
Video -
https://assets.json2video.com/examples/ ... lide-text- right.mp4
Ist das mit Moviepy Python möglich? Ich kann FFMPEG nicht verwenden, da es auf meinem Server nicht unterstützt wird.
Code: Select all
from moviepy.editor import *
# Load the image
img_clip = ImageClip("your_image.png")
# Set the duration of the image clip
img_clip = img_clip.set_duration(5)
# Resize the image if necessary
img_clip = img_clip.resize(height=1080) # Keep the height consistent
# Define your text
text = "Your Marketing Message"
# Create a TextClip
txt_clip = TextClip(text, fontsize=70, color='white')
# Set the duration of the text clip
txt_clip = txt_clip.set_duration(5)
# Animate the text to slide in from the right
def slide_in(t):
return 'center', -1000 + 1500 * t # Adjust these values based on your needs
txt_clip = txt_clip.set_position(slide_in)
# Set background color
txt_clip = txt_clip.on_color(size=(1920, 1080), color=(0, 0, 0), col_opacity=1)
# Position the image on the left side
img_clip = img_clip.set_position(('left', 'center'))
# Position the text clip on the right side
txt_clip = txt_clip.set_position(('right', 'center'))
# Composite the two clips together
final_clip = CompositeVideoClip([img_clip, txt_clip])
# Set the duration of the final clip
final_clip = final_clip.set_duration(5)
# Save the video
final_clip.write_videofile("image_and_slide_text.mp4", fps=24)