不为别的,只为做一个连自己都羡慕的人

python截取视频的某一部分,转为gif,作为视频的预览

from moviepy.editor import *
def samllVideoGif(_videoPath, _videoGifPath):
    # _videoPath = "C:\\Users\\sswc\\Desktop\\gai2\\public\\showPdf\\6f3db1f9-e247-4aa5-bca7-93bae62a0079.mp4"
    # _videoGifPath = "C:\\Users\\sswc\\Desktop\\gai2\\public\\showPdf\\6f3db1f9-e247-4aa5-bca7-93bae62a0079.gif"

    # clip = (VideoFileClip(_videoPath).subclip(1, 3).resize(0.1))  # 现在切割T = 4和6秒之间的剪辑  resize等比缩放 subclip截取很多秒
    clip = (VideoFileClip(_videoPath).subclip(1, 30).resize(1))
    clip.write_gif(_videoGifPath)  # gif将有30 fps

 

posted @ 2020-09-15 15:07  升级打怪  阅读(512)  评论(0编辑  收藏  举报