MovieLite provides a simple yet powerful API for basic video editing operations. This guide covers the fundamental techniques you’ll use in almost every project: cutting clips, concatenating sequences, positioning elements, and adjusting visual properties.
Position clips at specific coordinates using set_position():
from movielite import VideoClip, VideoWriterbackground = VideoClip("background.mp4", start=0)small_clip = VideoClip("overlay.mp4", start=0)# Resize the overlay to be smallersmall_clip.set_size(width=320, height=180)# Position in top-right corner (with 20px padding)small_clip.set_position((background.size[0] - 340, 20))writer = VideoWriter("output_positioned.mp4", fps=background.fps, size=background.size)writer.add_clips([background, small_clip])writer.write()background.close()small_clip.close()
Position can be a function of time for animated movement:
# Slide from left to center over 2 secondsdef slide_position(t): if t < 2.0: x = int(-320 + (video.size[0] // 2 + 320) * (t / 2.0)) else: x = video.size[0] // 2 y = video.size[1] // 2 return (x, y)clip.set_position(slide_position)
from movielite import VideoClip, VideoWriter# Normal speed introintro = VideoClip("intro.mp4", start=0, duration=3)intro.set_speed(1.0)# Fast action sequenceaction = VideoClip("action.mp4", start=intro.end, duration=10)action.set_speed(2.0) # Will play in 5 seconds# Slow motion highlighthighlight = VideoClip("highlight.mp4", start=action.end, duration=5)highlight.set_speed(0.5) # Will play in 10 secondswriter = VideoWriter("final.mp4", fps=30)writer.add_clips([intro, action, highlight])writer.write()for clip in [intro, action, highlight]: clip.close()
Speed changes affect both video frames and audio. The audio will be pitched up (faster) or down (slower) accordingly.
from movielite import VideoClip, VideoWriterclip = VideoClip("short_clip.mp4", duration=10)clip.loop(True) # Enable looping# The clip will loop to fill the 10-second durationwriter = VideoWriter("output_looped.mp4", fps=clip.fps, size=clip.size, duration=10)writer.add_clip(clip)writer.write()clip.close()