很多剪辑软件要收费,自己写了一个。

from moviepy.video.io.VideoFileClip import VideoFileClip

def trim_video(input_path, output_path, trim_duration):
    video_clip = VideoFileClip(input_path)
    trimmed_clip = video_clip.subclip(0, video_clip.duration - trim_duration)
    trimmed_clip.write_videofile(output_path, codec="libx264")
    trimmed_clip.close()
    video_clip.close()

input_video_path = "input.mp4"
output_video_path = "output.mp4"
trim_duration_seconds = 8  # 剪掉的秒数

trim_video(input_video_path, output_video_path, trim_duration_seconds)

参数设置:

video_clip.subclip(x,y):
x:开始时间
y:结束时间
input_video_path:输入文件路径
output_video_path:输出文件路径

具体实现:
上面的程序实现的是剪掉最后8s

09-03 04:57