moviepy简介
moviepy能够对音频,视频,以及git图片进行剪切,合并,标题插入等处理,并支持多种格式。
moviepy也是基于ffmpeg,如果没有安装ffmpeg,moviepy会在第一次使用moviepy的时候自动下载安装ffmpeg,如果本机安装有ffmpeg,建议修改config_defaults.py
文件中的配置为FFMPEG_BINARY = 'auto-detect'
至于其他工具,则是对应相应的工具自行决定要不要安装,比如增加文字需要ImageMagick,预览音频和视频需要PyGame
moviepy使用
moviepy的核心对象是clips
,可以是AudioClips
或 VideoClips
create clips
|
|
VideoClip
VideoClip
is the base class for all the other video clips in MoviePy. If all you want is to edit video files, you will never need it. This class is practical when you want to make animations from frames that are generated by another library. All you need is to define a function make_frame(t)
which returns a HxWx3 numpy array (of 8-bits integers) representing the frame at time t. Here is an example with the graphics library Gizeh
:
|
|
ImageSequenceClip
This is a clip made from a series of images, you call it with:
|
|
where images_list
can be either a list of image names (that will be played) in that order, a folder name (at which case all the image files in the folder will be played in alphanumerical order), or a list of frames (Numpy arrays), obtained for instance from other clips.
TextClip
Generating a TextClip requires to have ImageMagick installed and (for windows users) linked to MoviePy
Exporting video clips
|
|
Sometimes it is impossible for MoviePy to guess the duration
attribute of the clip (keep in mind that some clips, like ImageClips displaying a picture, have a priori an infinite duration). Then, the duration
must be set manually with clip.set_duration
:
|
|
To write your video as an animated GIF, use
|
|
You can write a frame to an image file with
|
|
concatenating clips
|
|
CompositeVideoClips
也能合并clips
|
|
Clips transformations and effects
|
|
Example Scripts
https://zulko.github.io/moviepy/examples/examples.html