有趣的python库-moviepy
moviepy-视频处理
安装:
pip install moviepy
基本使用:
from moviepy.video.compositing.CompositeVideoClip import clips_array from moviepy.video.compositing.concatenate import concatenate_videoclips from moviepy.editor import VideoFileClip def cut_mp4(): movie = VideoFileClip("优雅.mp4") begin = 23 # 剪切 movie1 = movie.subclip(begin, begin + 5) movie2 = movie.subclip(10, 15) # 提取音频 # audio = movie.audio # 等比缩小尺寸 # movie2 = movie.resize(0.60) # 拼接 movie3 = concatenate_videoclips([movie1, movie2]) # 画面拼接, 注意是列表嵌套 movie4 = clips_array([[movie1, movie2], [movie2, movie1]]) # 导出 movie4.write_videofile("youya4.mp4") if __name__ == '__main__': cut_mp4()
可以实现视频剪辑、画面拼接等处理视屏用的功能。想知道更多有意思的库可以我的《有意思的库》专栏,觉得有用就点个关注呗!