最近需要做动图,需要从视频中提取帧图片并进行裁剪缩放处理。
# -*- coding: utf-8 -*-
# !/usr/bin/python3
from PIL import Image
import os
import cv2
import imageio
'''
将视频帧转换为图片
'''
videoPath = './video.mp4'
frames = cv2.VideoCapture(videoPath)
c = 0
i = 0
timeF = 1
rval=frames.isOpened()
while rval: # 循环读取视频帧
c = c + 1
rval, frame = frames.read()
if (c % timeF == 0) and