v2.0 有重大破坏性变更,v1 代码需按迁移指南改写;底层依赖 FFMPEG,自定义安装需参考官方安装文档;因数据导入导出较重,速度比直接用 ffmpeg 慢
pip install moviepyREADME 未说明显存或 GPU 要求;可在 Windows/Mac/Linux 上运行,需 Python 3.9+
用 Python 做视频剪辑的库,把帧变成 numpy 数组,方便写自定义特效
用 Python 脚本剪辑视频,支持裁剪拼接、加字幕特效、导出 GIF 和调整帧率,适合批量处理和自动化视频流水线。
核心能力
- 将视频帧和音频转为 numpy 数组逐像素处理
- 支持剪切、拼接、叠加合成与文字标题插入
- 内置多种视频与音频特效,可用几行代码自定义
- 读写常见音视频格式,含 GIF 输出
容易踩的坑
- v2.2.1最新正式版2025-05-21 · 2025-05-21 19:31 UTC
What's Changed
- handle removed Pillow API by @Zulko in https://github.com/Zulko/moviepy/pull/2443
Full Changelog: https://github.com/Zulko/moviepy/compare/v2.2...v2.2.1
- v2.2v2.2.02025-05-21 · 2025-05-21 14:13 UTC
查看更新说明
Fixes and requirements tweaks
What's Changed
- chore: skip metadata which not satisfied with "key:value" by @asd55667 in https://github.com/Zulko/moviepy/pull/2311
- Add flac extension by @jonata in https://github.com/Zulko/moviepy/pull/2218
- libx264 and prores as mov codecs by @gustawdaniel in https://github.com/Zulko/moviepy/pull/2219
- Fix attribute check by @take0x in https://github.com/Zulko/moviepy/pull/2216
- Add bg_radius to text boxes by @aaa3334 in https://github.com/Zulko/moviepy/pull/2270
- Fix GPU h264_nvenc encoding not working. by @xiaomofa in https://github.com/Zulko/moviepy/pull/2121
- Fix decorator-related slow performance by @bzczb in https://github.com/Zulko/moviepy/pull/2095
- Fix forgotten print by @OsaAjani in https://github.com/Zulko/moviepy/pull/2314
- Update list of maintainers by @OsaAjani in https://github.com/Zulko/moviepy/pull/2316
- Bump pillow dependency by @OsaAjani in https://github.com/Zulko/moviepy/pull/2317
- Update issue template by @OsaAjani in https://github.com/Zulko/moviepy/pull/2321
- Fix textclip cutting text by @OsaAjani in https://github.com/Zulko/moviepy/pull/2326
- Fix issue #2286 on TimeMirror and TimeSymmetrize by @OsaAjani in https://github.com/Zulko/moviepy/pull/2328
- Add exception on outside of boundaries subclip by @OsaAjani in https://github.com/Zulko/moviepy/pull/2319
- Add support for new argument ch_layout on ffmpeg >= 7 and make compatible with ffmpeg 7 by @OsaAjani in https://github.com/Zulko/moviepy/pull/2331
- Fix issue #2330 audio write wrong fps by @Implosiv3 in https://github.com/Zulko/moviepy/pull/2336
- Fix Freeze effect removing original start and end parameters by @OsaAjani in https://github.com/Zulko/moviepy/pull/2339
- Add support for default pillow font by @OsaAjani in https://github.com/Zulko/moviepy/pull/2344
- Update config.py check() to log correct binary name by @cerushdope in https://github.com/Zulko/moviepy/pull/2345
- Use audio codec for existing audiofile by @zalgo3 in https://github.com/Zulko/moviepy/pull/2346
- Fix wrong fps calculation by @OsaAjani in https://github.com/Zulko/moviepy/pull/2352
- Fix incoherent frame seek as describe in issue #2115 and pr #2117 by @OsaAjani in https://github.com/Zulko/moviepy/pull/2353
- BugFix: Fix the alignment of audio duration and video duration after concatenate_videoflips by @zyw241 in https://github.com/Zulko/moviepy/pull/2201
- Fix text without spaces overflowing TextClip boundaries by @OsaAjani in https://github.com/Zulko/moviepy/pull/2357
- Fix ffmpeg_reader not selecting a default stream by @bzczb in https://github.com/Zulko/moviepy/pull/2114
New Contributors
- @asd55667 made their first contribution in https://github.com/Zulko/moviepy/pull/2311
- @jonata made their first contribution in https://github.com/Zulko/moviepy/pull/2218
- @gustawdaniel made their first contribution in https://github.com/Zulko/moviepy/pull/2219
- @take0x made their first contribution in https://github.com/Zulko/moviepy/pull/2216
- @aaa3334 made their first contribution in https://github.com/Zulko/moviepy/pull/2270
- @xiaomofa made their first contribution in https://github.com/Zulko/moviepy/pull/2121
- @bzczb made their first contribution in https://github.com/Zulko/moviepy/pull/2095
- @Implosiv3 made their first contribution in https://github.com/Zulko/moviepy/pull/2336
- @cerushdope made their first contribution in https://github.com/Zulko/moviepy/pull/2345
- @zalgo3 made their first contribution in https://github.com/Zulko/moviepy/pull/2346
- @zyw241 made their first contribution in https://github.com/Zulko/moviepy/pull/2201
Full Changelog: https://github.com/Zulko/moviepy/compare/v2.1.2...v2.2
- v2.1.22025-01-10 · 2025-01-10 11:53 UTC
查看更新说明
v2.1.2
Important Announcements
Transparency compositing and rendering have been completely fixed in this release. If you've experienced issues with transparency in the past, please try this update.
Added
- Codec extraction during ffmpeg meta parsing (if available).
Fixed
- Major refactor of ffmpeg reader and writer for transparency support.
- Overhaul of
CompositeVideoClipto properly handle transparency. - Fixed issue #2305: Changed
stroke_widthfrom float0.5to int1. - Fixed issue #2160: Crash when saving filenames starting with
-. - Fixed issue #2247: Incorrect default mask size of 1x1.
Upgrade now to take advantage of these fixes!
- v2.1.12024-11-25 · 2024-11-25 04:32 UTC
查看更新说明
What's Changed
- Make
FFMPEG_VideoReadermore robust to missing information. by @Breakthrough in https://github.com/Zulko/moviepy/pull/2253
Full Changelog: https://github.com/Zulko/moviepy/compare/v2.1.0...v2.1.1
- Make
- v2.1.02024-11-24 · 2024-11-24 23:44 UTC
查看更新说明
What's Changed
- More api changes by @Zulko in https://github.com/Zulko/moviepy/pull/2255
- example tweaks by @Zulko in https://github.com/Zulko/moviepy/pull/2258
- Fix invalid option in docstring of TextClip, as mentionned in #2251 by @OsaAjani in https://github.com/Zulko/moviepy/pull/2254
- docs: :memo: State python 3.9 instead of 3.7 support in readme by @Paillat-dev in https://github.com/Zulko/moviepy/pull/2245
- Ensure
last_readis always set. by @Breakthrough in https://github.com/Zulko/moviepy/pull/2257
New Contributors
- @Paillat-dev made their first contribution in https://github.com/Zulko/moviepy/pull/2245
- @Breakthrough made their first contribution in https://github.com/Zulko/moviepy/pull/2257
Full Changelog: https://github.com/Zulko/moviepy/compare/v2.0.0...v2.1.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
MoviePy
[!NOTE] MoviePy recently upgraded to v2.0, introducing major breaking changes. You can consult the last v1 docs here but beware that v1 is no longer maintained. For more info on how to update your code from v1 to v2, see this guide.
MoviePy (online documentation here) is a Python library for video editing: cuts, concatenations, title insertions, video compositing (a.k.a. non-linear editing), video processing, and creation of custom effects.
MoviePy can read and write all the most common audio and video formats, including GIF, and runs on Windows/Mac/Linux, with Python 3.9+.
Example
In this example we open a video file, select the subclip between 10 and 20 seconds, add a title at the center of the screen, and write the result to a new file:
from moviepy import VideoFileClip, TextClip, CompositeVideoClip
# Load file example.mp4 and keep only the subclip from 00:00:10 to 00:00:20
# Reduce the audio volume to 80% of its original volume
clip = (
VideoFileClip("long_examples/example2.mp4")
.subclipped(10, 20)
.with_volume_scaled(0.8)
)
# Generate a text clip. You can customize the font, color, etc.
txt_clip = TextClip(
font="Arial.ttf",
text="Hello there!",
font_size=70,
color='white'
).with_duration(10).with_position('center')
# Overlay the text clip on the first video clip
final_video = CompositeVideoClip([clip, txt_clip])
final_video.write_videofile("result.mp4")
How MoviePy works
Under the hood, MoviePy imports media (video frames, images, sounds) and converts them into Python objects (numpy arrays) so that every pixel becomes accessible, and video or audio effects can be defined in just a few lines of code (see the built-in effects for examples).
The library also provides ways to mix clips together (concatenations, playing clips side by side or on top of each other with transparency, etc.). The final clip is then encoded back into mp4/webm/gif/etc.
This makes MoviePy very flexible and approachable, albeit slower than using ffmpeg directly due to heavier data import/export operations.
Installation
Intall moviepy with pip install moviepy. For additional installation options, such as a custom FFMPEG or for previewing, see this section. For development, clone that repo locally and install with pip install -e .
Documentation
The online documentation (here) is automatically built at every push to the master branch. To build the documentation locally, install the extra dependencies via pip install "moviepy[doc]", then go to the docs folder and run make html.
Contribute
MoviePy is open-source software originally written by Zulko and released under the MIT licence. The project is hosted on GitHub, where everyone is welcome to contribute and open issues or give feedback Please read our Contributing Guidelines. To ask for help or simply discuss usage and examples, use our Reddit channel.
Maintainers
Active maintainers
- Zulko (owner)
- @osaajani led the development of v2 (MR)
- @tburrows13
- @keikoro
Past maintainers and thanks
Maintainers wanted! this library has only been kept afloat by the involvement of its maintainers, and there are times where none of us have enough bandwidth. We'd love to hear about developers interested in giving a hand and solving some of the issues (especially the ones that affect you) or reviewing pull requests. Open an issue or contact us directly if you are interested. Thanks!