Answer the question
In order to leave comments, you need to log in
How to speed up OpenCV video processing?
I have a video that is 21 seconds long, I took a simple program that will rewrite the video frame by frame to a new file, and although it does not even show the video, it takes 22 seconds to complete, there is something you can do to make it work faster, because most likely python can process video faster than 30 fps?
Program:
import cv2
cap = cv2.VideoCapture('video.mp4')
out = cv2.VideoWriter('output.mp4', -1, 20.0, (1920,1080))
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
out.write(frame)
else:
break
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question