I'm using python with OpenCV. I was passing an MP4 link to VideoCapture but then I found my code runs ~10X faster (including urllib download time) if I download the video file with urllib.request first and then pass the filename to VideoCapture.
My question is if there is a way to download a video clip (subject to my machine's hardware {and software} constraints) into a capture object and then just let that object get disposed of with the normal python garbage collection when I am done with it?
Saving a video file to disk is slow compared to just loading it into memory. Any suggestions on how to do this with an internet file?
urllib doesn't have to save the downloaded object to disk so all I needed to do was:
import urllib.request
url = 'https://previews.customer.envatousercontent.com/h264-video-previews/f331148f-3aa1-42ff-ae89-1a67274f2bd6/2009010.mp4'
video, http = urllib.request.urlretrieve(url)
cap = cv2.VideoCapture(video)