Scripts2026年3月29日·1 分钟阅读

MoviePy — Python Video Editing Library

Python library for video editing: cutting, concatenating, adding titles, effects, and audio. Script-based video production for automation pipelines.

TO
TokRepo精选 · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

pip install moviepy
from moviepy import VideoFileClip, TextClip, CompositeVideoClip

video = VideoFileClip("input.mp4").subclipped(0, 10)
title = TextClip(text="Hello World", font_size=70, color="white", font="Arial")
title = title.with_duration(5).with_position("center")
result = CompositeVideoClip([video, title])
result.write_videofile("output.mp4")

介绍

MoviePy is a Python library for video editing — cutting, concatenating, adding text overlays, transitions, and effects through code. No GUI needed. Perfect for building automated video production pipelines where you need to programmatically assemble, transform, and export videos. 13,000+ GitHub stars.

Best for: Automated video assembly, batch processing, adding overlays/titles to existing footage Works with: Python 3.9+, FFmpeg (auto-installed) Setup time: 2 minutes


Key Operations

Cut and trim

clip = VideoFileClip("video.mp4").subclipped(10, 60)  # 10s to 60s

Concatenate clips

from moviepy import concatenate_videoclips
final = concatenate_videoclips([clip1, clip2, clip3])

Add text overlay

txt = TextClip(text="Subscribe!", font_size=40, color="yellow", font="Arial")
txt = txt.with_duration(3).with_position(("center", "bottom"))

Resize and speed

clip = clip.resized(width=1080)
clip = clip.with_speed_scaled(2.0)  # 2x speed

FAQ

Q: What is MoviePy? A: A Python library for video editing through code — cut, concatenate, overlay text, apply effects, and export videos programmatically without a GUI.

Q: Is MoviePy free? A: Yes. MoviePy is MIT-licensed and free to use.


🙏

来源与感谢

Created by Zulko. Licensed under MIT. moviepy — ⭐ 13,000+ Docs: zulko.github.io/moviepy

相关资产