[英]Convert video into individual frames using Python without ffmpeg?
我需要比較 2 個視頻以檢查它們是否相同。
所以我打算做以下事情:
Python Image Lib
將每一幀與參考視頻的相應幀進行比較 我想知道 Python 中是否有任何函數可以幫助我完成第一步,即將視頻拆分為單獨的幀。 我不想使用ffmpeg
進行拆分。
在此先感謝您的幫助
你可以使用opencv
import cv2
video_capture = cv2.VideoCapture("rtsp://admin:admin@192.168.0.94:554/stream3")
while True:
# get frame by frame
ret, frame = video_capture.read()
cv2.imwrite('pic.png',frame)
cv2.imshow('Video', frame)
嘗試這個:
currentFrame = 0
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Saves image of the current frame in jpg file
name = './data/frame' + str(currentFrame) + '.jpg'
print ('Creating...' + name)
cv2.imwrite(name, frame)
# To stop duplicate images
currentFrame += 1
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
#you can use this method
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.