Skills2026年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.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
MoviePy — Python Video Editing Library
直接安装命令
npx -y tokrepo@latest install 57b68929-f919-474a-99f1-81ac76e0bce6 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
MoviePy is a Python library for programmatic video editing: cutting, concatenation, titles, effects, and audio manipulation.
§01

What it is

MoviePy is a Python library for video editing that handles cutting, concatenating, adding titles, applying effects, and mixing audio. Instead of using a GUI video editor, you write Python scripts that process video files programmatically. This makes it suitable for batch processing, automated video pipelines, and integration with other Python tools.

MoviePy targets developers and content creators who need automated video processing: generating social media clips from long recordings, adding watermarks to batches of videos, or building video generation pipelines.

§02

How it saves time or tokens

MoviePy replaces manual video editing for repetitive tasks. Cutting 100 clips from a long recording, adding consistent intros/outros to a batch of videos, or resizing videos for different platforms are all tasks that take hours manually but minutes with a script.

The library wraps FFmpeg, so you get professional-grade video processing without learning FFmpeg's complex command-line syntax.

§03

How to use

  1. Install MoviePy:
pip install moviepy
  1. Basic video operations:
from moviepy import VideoFileClip, TextClip, CompositeVideoClip

video = VideoFileClip('input.mp4')

# Cut a clip (seconds 10 to 30)
clip = video.subclipped(10, 30)

# Add a title
title = TextClip(
    text='My Title',
    font_size=48,
    color='white',
    duration=5
)
final = CompositeVideoClip([clip, title.with_position('center')])
final.write_videofile('output.mp4')
  1. Concatenate multiple clips:
from moviepy import concatenate_videoclips

clips = [VideoFileClip(f'clip_{i}.mp4') for i in range(5)]
result = concatenate_videoclips(clips)
result.write_videofile('combined.mp4')
§04

Example

Batch processing videos with watermark and resize:

import os
from moviepy import VideoFileClip, ImageClip, CompositeVideoClip

logo = ImageClip('logo.png').with_duration(None).resized(height=50)

for filename in os.listdir('raw_videos/'):
    if not filename.endswith('.mp4'):
        continue
    video = VideoFileClip(f'raw_videos/{filename}')
    video = video.resized(width=1080)
    watermarked = CompositeVideoClip([
        video,
        logo.with_position(('right', 'bottom'))
    ])
    watermarked.write_videofile(f'output/{filename}')
§05

Related on TokRepo

§06

Common pitfalls

  • Memory issues with large video files. MoviePy loads frames into memory during processing. For long videos, process in chunks or use FFmpeg directly for simple operations.
  • Font rendering on headless servers. TextClip requires ImageMagick, which may not be installed on server environments. Install ImageMagick and set the correct path in MoviePy's config.
  • Slow rendering with many effects. Each effect layer adds processing time per frame. For production pipelines, pre-render assets and minimize real-time compositing.

常见问题

Does MoviePy require FFmpeg?+

Yes. MoviePy uses FFmpeg for reading and writing video files. It is bundled with the imageio-ffmpeg package, which is installed automatically with MoviePy. No manual FFmpeg installation is needed in most cases.

Can MoviePy handle 4K video?+

Yes, but performance depends on available RAM and CPU. Processing 4K video is memory-intensive. For batch 4K processing, consider using FFmpeg directly for simple operations and MoviePy for complex compositing.

What video formats does MoviePy support?+

MoviePy supports any format that FFmpeg supports: MP4, AVI, MOV, MKV, WebM, and many others. MP4 with H.264 codec is the most common output format. GIF output is also supported.

Can I add audio to videos with MoviePy?+

Yes. MoviePy handles audio natively. You can add background music, mix audio tracks, adjust volume, and sync audio with video. The AudioFileClip class loads standalone audio files.

Is MoviePy suitable for real-time video processing?+

No. MoviePy is designed for offline video editing and rendering. For real-time video processing, use OpenCV or GStreamer. MoviePy processes frames sequentially and writes to disk.

引用来源 (3)
🙏

来源与感谢

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产