import os
from moviepy.editor import VideoFileClip
video_dir = r"E:\学习\视频剪辑"
s_video_file = "1.mp4"
d_video_file = "剪辑片段1.mp4"
s_video_path = os.path.join(video_dir, s_video_file) # 原视频文件路径
d_video_path = os.path.join(video_dir, d_video_file) # 目标视频文件路径
# 读取视频文件
video = VideoFileClip(s_video_path)
# 剪辑指定片段
clip = video.subclip(10, 20) # 单位是秒,表示10秒到20秒片段
#clip = video.subclip(1*60 + 30, 2*60 + 45) #表示1:30秒到2:45秒片段
# 输出剪辑后的视频
clip.write_videofile(d_video_path)
输出如下: