Sayfalar

Translate Blog

7 Haziran 2023 Çarşamba

Videoları Python ile frame başı bir resim olarak kaydedin / convert video to images by frame via python

Videonuzu python ile kolayca framelere ayırabilirsiniz. Her framede 1 resim olacak şekilde resimleri elde edebilirsiniz.


import cv2
import numpy as np
import skimage.exposure
vidcap = cv2.VideoCapture('videoname.mp4') #video file name here
success,image = vidcap.read()
count = 0
while success:
  cv2.imwrite("res/frame%d.jpg" % count, image) # save frame folder res as jpg file      
  #if count>300:
  #  break
  count += 1
  success,image = vidcap.read()