python简单裁剪视频

import os
import json
from moviepy.video.io.VideoFileClip import VideoFileClip

def clip_video(source_file_lip, target_file, start_time, stop_time):
    video = source_file_lip.subclip(int(start_time), int(stop_time))  # 执行剪切操作
    video.write_videofile(target_file)  # 输出文件

def test_example():
    
    root_path = '1/'
    list = os.listdir(root_path)
    for video_name in list:
        source_file = root_path + video_name
        source_file_lip = VideoFileClip(source_file)
        start_time = 9.0
        stop_time = source_file_lip.duration - 2
        target_file =  "2/" + video_name + ".mp4"
if __name__ == "__main__":
    test_example()

你可能感兴趣的:(语言类)