I want to parse a .webm file in the VP9 codec using Python and no modules. I know this sounds stupid and/or useless but I have to.
I would like to have some kind of function "extract_frames" that would extract every frame of a webm. The "frame format" does not have to be anything specific, but it will ultimately be converted to a 2-dimensional list of colours.
I repeat: I cannot use any Python modules.
NOTE: I can switch to another video format, my goal is just to extract the frames using no modules. It's better to have a small video format.
I'm thinking about transcribing this https://github.com/webmproject/libvpx/tree/main/vp9/decoder into Python but I wish for an easier solution...
I tried using cv2.VideoCapture and that's exactly what I want, but I have to use pure Python with no modules. Here is my code :
import cv2
video = cv2.VideoCapture(r'./video.mp4')
currentframe = 0
while(True):
ret,frame = video.read()
if ret:
# "frame" here is perfect
currentframe += 1
else:
break
video.release()
cv2.destroyAllWindows()
This is probably not the best solution for every use case but for mine, I decided to go with that :
I'm optimising this, but that's the basic solution I ended up finding.